diff options
| author | hathach <[email protected]> | 2019-03-22 22:06:48 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-03-22 22:06:48 +0700 |
| commit | ba1bea5d536d232cd5e535ff33ac372f7dd9a575 (patch) | |
| tree | feef6ec32375ce3c0eb96006b9560476b5ab4a11 /hw | |
| parent | 2533f4004eb936cde565b58ea747dd90f981b8c5 (diff) | |
simplify board API, adding stm32f3 discovery
- remove board header since it is not used
Diffstat (limited to 'hw')
25 files changed, 388 insertions, 486 deletions
diff --git a/hw/bsp/board.h b/hw/bsp/board.h index 6b432d2e5..ec0b1311a 100644 --- a/hw/bsp/board.h +++ b/hw/bsp/board.h @@ -40,53 +40,33 @@ #include "ansi_escape.h" -// NXP LPC -#if defined BOARD_LPCXPRESSO11U14 - #include "lpcxpresso11u14/board_lpcxpresso11u14.h" -#elif defined BOARD_LPCXPRESSO1347 - #include "lpcxpresso1347/board_lpcxpresso1347.h" -#elif defined BOARD_LPCXPRESSO11U68 - #include "lpcxpresso11u68/board_lpcxpresso11u68.h" -#elif defined BOARD_LPCXPRESSO1769 - #include "lpcxpresso1769/board_lpcxpresso1769.h" -#elif defined BOARD_MCB1800 - #include "mcb1800/board_mcb1800.h" -#elif defined BOARD_EA4088QS - #include "ea4088qs/board_ea4088qs.h" -#elif defined BOARD_EA4357 - #include "ea4357/board_ea4357.h" - -// Nordic nRF -#elif defined BOARD_PCA10056 - #include "pca10056/board_pca10056.h" - -// Atmel SAM -#elif defined BOARD_METRO_M4_EXPRESS - #include "metro_m4_express/board_metro_m4_express.h" -#elif defined BOARD_METRO_M0_EXPRESS - #include "metro_m0_express/board_metro_m0_express.h" - -// ST STM32 -#elif defined BOARD_STM32F407G_DISC1 - #include "stm32f407g_disc1/board_stm32f407g_disc1.h" -#else - #error BOARD is not defined or supported yet -#endif - #define CFG_UART_BAUDRATE 115200 #define BOARD_TICKS_HZ 1000 #define board_tick2ms(tck) ( ( ((uint64_t)(tck)) * 1000) / BOARD_TICKS_HZ ) +//--------------------------------------------------------------------+ +// Board Porting API +//--------------------------------------------------------------------+ -// Initialize on-board peripherals +// Initialize on-board peripherals : led, button, uart and USB void board_init(void); -//--------------------------------------------------------------------+ -// LED -// Board layer use only 1 LED for indicator -//--------------------------------------------------------------------+ +// Turn LED on or off void board_led_control(bool state); +// Get the current state of buttons on the board +// \return Bitmask where a '1' means active (pressed), a '0' means inactive. +uint32_t board_buttons(void); + +// Get characters from UART +int board_uart_read(uint8_t* buf, int len); + +// Send characters to UART +int board_uart_write(void const * buf, int len); + +//--------------------------------------------------------------------+ +// Helper functions +//--------------------------------------------------------------------+ static inline void board_led_on(void) { board_led_control(true); @@ -97,26 +77,6 @@ static inline void board_led_off(void) board_led_control(false); } -//--------------------------------------------------------------------+ -// Buttons -// TODO refractor later -//--------------------------------------------------------------------+ -/** Get the current state of the buttons on the board - * \return Bitmask where a '1' means active (pressed), a '0' means inactive. - */ -uint32_t board_buttons(void); - -//--------------------------------------------------------------------+ -// UART -//--------------------------------------------------------------------+ - -// Get characters from UART -int board_uart_read(uint8_t* buf, int len); - -// Send characters to UART -int board_uart_write(void const * buf, int len); - - static inline int8_t board_uart_getchar(void) { uint8_t c; diff --git a/hw/bsp/ea4088qs/board_ea4088qs.c b/hw/bsp/ea4088qs/board_ea4088qs.c index b0ce7281b..d8ab2973d 100644 --- a/hw/bsp/ea4088qs/board_ea4088qs.c +++ b/hw/bsp/ea4088qs/board_ea4088qs.c @@ -26,8 +26,10 @@ #ifdef BOARD_EA4088QS +#include "chip.h" #include "../board.h" -#include "tusb.h" + +#include "tusb_option.h" #define LED_PORT 2 #define LED_PIN 19 diff --git a/hw/bsp/ea4088qs/board_ea4088qs.h b/hw/bsp/ea4088qs/board_ea4088qs.h deleted file mode 100644 index 45a957065..000000000 --- a/hw/bsp/ea4088qs/board_ea4088qs.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_EA4088QS_H_ -#define BOARD_EA4088QS_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_EA4088QS_H_ */ diff --git a/hw/bsp/ea4357/board_ea4357.c b/hw/bsp/ea4357/board_ea4357.c index d44082551..a9af16633 100644 --- a/hw/bsp/ea4357/board_ea4357.c +++ b/hw/bsp/ea4357/board_ea4357.c @@ -26,9 +26,11 @@ #ifdef BOARD_EA4357 +#include "chip.h" #include "../board.h" #include "pca9532.h" -#include "tusb.h" + +#include "tusb_option.h" #define BOARD_UART_PORT LPC_USART0 #define BOARD_UART_PIN_PORT 0x0f diff --git a/hw/bsp/ea4357/board_ea4357.h b/hw/bsp/ea4357/board_ea4357.h deleted file mode 100644 index b0e138f4f..000000000 --- a/hw/bsp/ea4357/board_ea4357.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef _TUSB_BOARD_EA4357_H_ -#define _TUSB_BOARD_EA4357_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_BOARD_EA4357_H_ */ diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c index ab05c045a..472204d66 100644 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c +++ b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.c @@ -26,6 +26,7 @@ #ifdef BOARD_LPCXPRESSO11U68 +#include "chip.h" #include "../board.h" #define LED_PORT 2 diff --git a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.h b/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.h deleted file mode 100644 index 3e8b2aded..000000000 --- a/hw/bsp/lpcxpresso11u68/board_lpcxpresso11u68.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef _TUSB_BOARD_LPCXPRESSO11U68_H_ -#define _TUSB_BOARD_LPCXPRESSO11U68_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_BOARD_LPCXPRESSO11U68_H_ */ diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c index 325577cd7..e7ed229a5 100644 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c +++ b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.c @@ -26,6 +26,7 @@ #ifdef BOARD_LPCXPRESSO1347 +#include "chip.h" #include "../board.h" #define LED_PORT 0 diff --git a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h b/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h deleted file mode 100644 index d20bc8c16..000000000 --- a/hw/bsp/lpcxpresso1347/board_lpcxpresso1347.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef _TUSB_BOARD_LPCXPRESSO1347_H_ -#define _TUSB_BOARD_LPCXPRESSO1347_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_BOARD_LPCXPRESSO1347_H_ */ diff --git a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c index 5ee799da5..32273aa75 100644 --- a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c +++ b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.c @@ -26,8 +26,10 @@ #ifdef BOARD_LPCXPRESSO1769 +#include "chip.h" #include "../board.h" -#include "tusb.h" + +#include "tusb_option.h" #define LED_PORT 0 #define LED_PIN 22 diff --git a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.h b/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.h deleted file mode 100644 index c6191c0d9..000000000 --- a/hw/bsp/lpcxpresso1769/board_lpcxpresso1769.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ - -#ifndef _TUSB_BOARD_LPCXPRESSO1769_H_ -#define _TUSB_BOARD_LPCXPRESSO1769_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* _TUSB_BOARD_LPCXPRESSO1769_H_ */ diff --git a/hw/bsp/mcb1800/board_mcb1800.c b/hw/bsp/mcb1800/board_mcb1800.c index 9989b334f..b7ddf46eb 100644 --- a/hw/bsp/mcb1800/board_mcb1800.c +++ b/hw/bsp/mcb1800/board_mcb1800.c @@ -26,8 +26,10 @@ #ifdef BOARD_MCB1800 +#include "chip.h" #include "../board.h" -#include "tusb.h" + +#include "tusb_option.h" #define LED_PORT 6 #define LED_PIN 24 diff --git a/hw/bsp/mcb1800/board_mcb1800.h b/hw/bsp/mcb1800/board_mcb1800.h deleted file mode 100644 index 1b1694837..000000000 --- a/hw/bsp/mcb1800/board_mcb1800.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_MCB1800_H_ -#define BOARD_MCB1800_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "chip.h" - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_MCB1800_H_ */ diff --git a/hw/bsp/metro_m0_express/board.mk b/hw/bsp/metro_m0_express/board.mk index 1844eeec8..0776ea567 100644 --- a/hw/bsp/metro_m0_express/board.mk +++ b/hw/bsp/metro_m0_express/board.mk @@ -7,7 +7,7 @@ CFLAGS += \ -mcpu=cortex-m0plus \ -msoft-float \ -mfloat-abi=soft \ - -nostdlib + -nostdlib -nostartfiles # All source paths should be relative to the top level. LD_FILE = hw/bsp/metro_m0_express/samd21g18a_flash.ld diff --git a/hw/bsp/metro_m0_express/board_metro_m0_express.h b/hw/bsp/metro_m0_express/board_metro_m0_express.h deleted file mode 100644 index a681c54b4..000000000 --- a/hw/bsp/metro_m0_express/board_metro_m0_express.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_METRO_M0_EXPRESS_H_ -#define BOARD_METRO_M0_EXPRESS_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "sam.h" - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_METRO_M0_EXPRESS_H_ */ diff --git a/hw/bsp/metro_m4_express/board.mk b/hw/bsp/metro_m4_express/board.mk index a560c5149..827613723 100644 --- a/hw/bsp/metro_m4_express/board.mk +++ b/hw/bsp/metro_m4_express/board.mk @@ -6,7 +6,7 @@ CFLAGS += \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ - -nostdlib + -nostdlib -nostartfiles CFLAGS += -Wno-error=undef diff --git a/hw/bsp/metro_m4_express/board_metro_m4_express.h b/hw/bsp/metro_m4_express/board_metro_m4_express.h deleted file mode 100644 index fb6f436fe..000000000 --- a/hw/bsp/metro_m4_express/board_metro_m4_express.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_METRO_M4_EXPRESS_H_ -#define BOARD_METRO_M4_EXPRESS_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#include "sam.h" - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_METRO_M4_EXPRESS_H_ */ diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c index f237e1368..c82b1544f 100644 --- a/hw/bsp/pca10056/board_pca10056.c +++ b/hw/bsp/pca10056/board_pca10056.c @@ -26,6 +26,8 @@ #ifdef BOARD_PCA10056 #include "bsp/board.h" + +#include "nrfx.h" #include "nrfx/hal/nrf_gpio.h" #include "nrfx/drivers/include/nrfx_power.h" #include "nrfx/drivers/include/nrfx_qspi.h" diff --git a/hw/bsp/pca10056/board_pca10056.h b/hw/bsp/pca10056/board_pca10056.h deleted file mode 100644 index 802da74d9..000000000 --- a/hw/bsp/pca10056/board_pca10056.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_PCA10056_H_ -#define BOARD_PCA10056_H_ - -#include "nrfx.h" -#include "nrfx_qspi.h" - -#ifdef __cplusplus - extern "C" { -#endif - -// Flash type used for MSC example -#define BOARD_MSC_FLASH_QSPI -#define BOARD_MSC_FLASH_SIZE (8*1024*1024) - -//#define BOARD_MSC_FLASH_RAM -// #define BOARD_MSC_FLASH_SIZE (8*1024) // 8KB is the smallest size that windows allow to mount - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_PCA10056_H_ */ diff --git a/hw/bsp/stm32f303disc/STM32F303VCTx_FLASH.ld b/hw/bsp/stm32f303disc/STM32F303VCTx_FLASH.ld new file mode 100644 index 000000000..ca9046d29 --- /dev/null +++ b/hw/bsp/stm32f303disc/STM32F303VCTx_FLASH.ld @@ -0,0 +1,189 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F303VCTx Device with +** 256KByte FLASH, 40KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +** (c)Copyright Ac6. +** You may use this file as-is or modify it according to the needs of your +** project. Distribution of this file (unmodified or modified) is not +** permitted. Ac6 permit registered System Workbench for MCU users the +** rights to distribute the assembled, compiled & linked contents of this +** file as part of an application binary file, provided that it is built +** using the System Workbench for MCU toolchain. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x2000a000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x800;; /* required amount of heap */ +_Min_Stack_Size = 0x800;; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 40K +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 8K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/hw/bsp/stm32f303disc/board.mk b/hw/bsp/stm32f303disc/board.mk new file mode 100644 index 000000000..5b558c1ec --- /dev/null +++ b/hw/bsp/stm32f303disc/board.mk @@ -0,0 +1,37 @@ +CFLAGS += \ + -DHSE_VALUE=8000000 \ + -DCFG_TUSB_MCU=OPT_MCU_STM32F3 \ + -DSTM32F303xC \ + -mthumb \ + -mabi=aapcs-linux \ + -mcpu=cortex-m4 \ + -mfloat-abi=hard \ + -mfpu=fpv4-sp-d16 \ + -nostdlib -nostartfiles + +# All source paths should be relative to the top level. +LD_FILE = hw/bsp/stm32f303disc/STM32F303VCTx_FLASH.ld + +LDFLAGS += -mthumb -mcpu=cortex-m4 + +SRC_C += \ + hw/mcu/st/system-init/system_stm32f3xx.c + +SRC_S += \ + hw/mcu/st/startup/stm32f3/startup_stm32f303xc.s + +INC += \ + -I$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F3xx/Include \ + -I$(TOP)/hw/mcu/st/cmsis + +VENDOR = st +CHIP_FAMILY = stm32f4 + +JLINK_DEVICE = stm32f303vc + +# Path to STM32 Cube Programmer CLI, should be added into system path +STM32Prog = STM32_Programmer_CLI + +# flash target using on-board stlink +flash: $(BUILD)/$(BOARD)-firmware.elf + $(STM32Prog) --connect port=swd --write $< --go diff --git a/hw/bsp/stm32f303disc/board_stm32f303disc.c b/hw/bsp/stm32f303disc/board_stm32f303disc.c new file mode 100644 index 000000000..99419b310 --- /dev/null +++ b/hw/bsp/stm32f303disc/board_stm32f303disc.c @@ -0,0 +1,122 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2018, hathach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#include "../board.h" +#include "stm32f3xx.h" + +#include "tusb_option.h" + +void board_init(void) +{ + // Init the LED on PD14 + RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; + GPIOD->MODER |= GPIO_MODER_MODE14_0; + + // USB Clock init + // PLL input- 8 MHz (External oscillator clock; HSI clock tolerance isn't + // tight enough- 1%, need 0.25%) + // VCO input- 1 to 2 MHz (2 MHz, M = 4) + // VCO output- 100 to 432 MHz (144 MHz, N = 72) + // Main PLL out- <= 180 MHz (18 MHz, P = 3- divides by 8) + // USB PLL out- 48 MHz (Q = 3) + RCC->PLLCFGR = RCC_PLLCFGR_PLLSRC_HSE | (3 << RCC_PLLCFGR_PLLQ_Pos) | \ + (3 << RCC_PLLCFGR_PLLP_Pos) | (72 << RCC_PLLCFGR_PLLN_Pos) | \ + (4 << RCC_PLLCFGR_PLLM_Pos); + + // Wait for external clock to become ready + RCC->CR |= RCC_CR_HSEON; + while(!(RCC->CR & RCC_CR_HSERDY_Msk)); + + // Wait for PLL to become ready + RCC->CR |= RCC_CR_PLLON; + while(!(RCC->CR & RCC_CR_PLLRDY_Msk)); + + // Switch clocks! + RCC->CFGR |= RCC_CFGR_SW_1; + + // Notify runtime of frequency change. + SystemCoreClockUpdate(); + // Systick init + #if CFG_TUSB_OS == OPT_OS_NONE + SysTick_Config(SystemCoreClock / 1000); + #endif + + RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN; + + // USB Pin Init + // PA9- VUSB, PA10- ID, PA11- DM, PA12- DP + // PC0- Power on + RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; + GPIOA->MODER |= GPIO_MODER_MODE9_1 | GPIO_MODER_MODE10_1 | \ + GPIO_MODER_MODE11_1 | GPIO_MODER_MODE12_1; + GPIOA->AFR[1] |= (10 << GPIO_AFRH_AFSEL9_Pos) | \ + (10 << GPIO_AFRH_AFSEL10_Pos) | (10 << GPIO_AFRH_AFSEL11_Pos) | \ + (10 << GPIO_AFRH_AFSEL12_Pos); + + // Pullup required on ID, despite the manual claiming there's an + // internal pullup already (page 1245, Rev 17) + GPIOA->PUPDR |= GPIO_PUPDR_PUPD10_0; +} + + +void board_led_control(bool state) +{ + if (!state) { + GPIOD->BSRR = GPIO_BSRR_BR14; + } else { + GPIOD->BSRR = GPIO_BSRR_BS14; + } +} + + +/*------------------------------------------------------------------*/ +/* TUSB HAL MILLISECOND + *------------------------------------------------------------------*/ +#if CFG_TUSB_OS == OPT_OS_NONE +volatile uint32_t system_ticks = 0; + +void SysTick_Handler (void) +{ + system_ticks++; +} + +uint32_t tusb_hal_millis(void) +{ + return board_tick2ms(system_ticks); +} +#endif + +void HardFault_Handler (void) +{ + asm("bkpt"); +} + +// Required by __libc_init_array in startup code if we are compiling using +// -nostdlib/-nostartfiles. +void _init(void) +{ + +} diff --git a/hw/bsp/stm32f407g_disc1/board.mk b/hw/bsp/stm32f407g_disc1/board.mk index 73d64a6bd..e966f998c 100644 --- a/hw/bsp/stm32f407g_disc1/board.mk +++ b/hw/bsp/stm32f407g_disc1/board.mk @@ -7,7 +7,7 @@ CFLAGS += \ -mcpu=cortex-m4 \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ - -nostdlib + -nostdlib -nostartfiles # All source paths should be relative to the top level. LD_FILE = hw/bsp/stm32f407g_disc1/STM32F407VGTx_FLASH.ld @@ -29,20 +29,8 @@ CHIP_FAMILY = stm32f4 JLINK_DEVICE = stm32f407vg -# Path to STM32 Cube Programmer CLI -ifeq ($(OS),Windows_NT) - STM32Prog = C:/Program Files/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI -else - UNAME_S := $(shell uname -s) - - ifeq ($(UNAME_S),Linux) - STM32Prog = $(HOME)/STMicroelectronics/STM32Cube/STM32CubeProgrammer/bin/STM32_Programmer_CLI - endif - - ifeq ($(UNAME_S),Darwin) - STM32Prog = STM32_Programmer_CLI - endif -endif +# Path to STM32 Cube Programmer CLI, should be added into system path +STM32Prog = STM32_Programmer_CLI # flash target using on-board stlink flash: $(BUILD)/$(BOARD)-firmware.elf diff --git a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c b/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c index 386356080..bf45eb5a0 100644 --- a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c +++ b/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.c @@ -24,15 +24,12 @@ * This file is part of the TinyUSB stack. */ -#include "bsp/board.h" +#include "../board.h" #include "stm32f4xx.h" #include "tusb_option.h" -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM DECLARATION -//--------------------------------------------------------------------+ void board_init(void) { // Init the LED on PD14 diff --git a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.h b/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.h deleted file mode 100644 index 833e26489..000000000 --- a/hw/bsp/stm32f407g_disc1/board_stm32f407g_disc1.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018, hathach (tinyusb.org) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * This file is part of the TinyUSB stack. - */ -#ifndef BOARD_STM32F407G_DISC1_H_ -#define BOARD_STM32F407G_DISC1_H_ - -#ifdef __cplusplus - extern "C" { -#endif - -#define BOARD_LED_NUM 1 -#define BOARD_LED0 62 - -#ifdef __cplusplus - } -#endif - -#endif /* BOARD_STM32F407G_DISC1_H_ */ |
