diff --git a/board/board.h b/board/board.h index 7de4b20..2f9d230 100644 --- a/board/board.h +++ b/board/board.h @@ -33,25 +33,12 @@ /* * Board identifier. */ -#define BOARD_ST_STM32F072B_DISCOVERY -#define BOARD_NAME "ST STM32F072B-Discovery" +#define BOARD_NAME "Twinkle Stick V2" -/* - * Board oscillators-related settings. - * NOTE: LSE not fitted. - * NOTE: HSE not fitted. - */ -#if !defined(STM32_LSECLK) #define STM32_LSECLK 0U -#endif - #define STM32_LSEDRV (3U << 3U) -#if !defined(STM32_HSECLK) -#define STM32_HSECLK 0U -#endif - -#define STM32_HSE_BYPASS +#define STM32_HSECLK 8000000U /* * MCU type as defined in the ST header. diff --git a/board/cfg/board.chcfg b/board/cfg/board.chcfg deleted file mode 100644 index e6ceecb..0000000 --- a/board/cfg/board.chcfg +++ /dev/null @@ -1,703 +0,0 @@ - - - - - resources/gencfg/processors/boards/stm32f0xx/templates - .. - 5.0.x - - ST STM32F072B-Discovery - ST_STM32F072B_DISCOVERY - - STM32F072xB - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/board/cfg/board.fmpp b/board/cfg/board.fmpp deleted file mode 100644 index 55cd396..0000000 --- a/board/cfg/board.fmpp +++ /dev/null @@ -1,15 +0,0 @@ -sourceRoot: ../../../../../tools/ftl/processors/boards/stm32f0xx/templates -outputRoot: .. -dataRoot: . - -freemarkerLinks: { - lib: ../../../../../tools/ftl/libs -} - -data : { - doc1:xml ( - board.chcfg - { - } - ) -} diff --git a/cfg/portab.c b/cfg/portab.c deleted file mode 100644 index 893c1e7..0000000 --- a/cfg/portab.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file portab.c - * @brief Application portability module code. - * - * @addtogroup application_portability - * @{ - */ - -#include "hal.h" - -#include "portab.h" - -/*===========================================================================*/ -/* Module local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module exported functions. */ -/*===========================================================================*/ - -void portab_setup(void) { - -} - -/** @} */ diff --git a/cfg/portab.h b/cfg/portab.h deleted file mode 100644 index 8ca603a..0000000 --- a/cfg/portab.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file portab.h - * @brief Application portability macros and structures. - * - * @addtogroup application_portability - * @{ - */ - -#ifndef PORTAB_H -#define PORTAB_H - -/*===========================================================================*/ -/* Module constants. */ -/*===========================================================================*/ - -#define PORTAB_USB1 USBD1 - -#define PORTAB_SDU1 SDU1 - -#define PORTAB_BLINK_LED1 LINE_LED_RED - -/*===========================================================================*/ -/* Module pre-compile time settings. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Derived constants and error checks. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module data structures and types. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Module macros. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - void portab_setup(void); -#ifdef __cplusplus -} -#endif - -/*===========================================================================*/ -/* Module inline functions. */ -/*===========================================================================*/ - -#endif /* PORTAB_H */ - -/** @} */ diff --git a/main.c b/main.c index deafa13..5f45458 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,6 @@ #include "ch.h" #include "hal.h" -#include "portab.h" #include "shell.h" #include "chprintf.h" @@ -61,12 +60,12 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) { while (chnGetTimeout((BaseChannel *)chp, TIME_IMMEDIATE) == Q_TIMEOUT) { #if 1 /* Writing in channel mode.*/ - chnWrite(&PORTAB_SDU1, buf, sizeof buf - 1); + chnWrite(&SDU1, buf, sizeof buf - 1); #else /* Writing in buffer mode.*/ - (void) obqGetEmptyBufferTimeout(&PORTAB_SDU1.obqueue, TIME_INFINITE); - memcpy(PORTAB_SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); - obqPostFullBuffer(&PORTAB_SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE); + (void) obqGetEmptyBufferTimeout(&SDU1.obqueue, TIME_INFINITE); + memcpy(SDU1.obqueue.ptr, buf, SERIAL_USB_BUFFERS_SIZE); + obqPostFullBuffer(&SDU1.obqueue, SERIAL_USB_BUFFERS_SIZE); #endif } chprintf(chp, "\r\n\nstopped\r\n"); @@ -78,7 +77,7 @@ static const ShellCommand commands[] = { }; static const ShellConfig shell_cfg1 = { - (BaseSequentialStream *)&PORTAB_SDU1, + (BaseSequentialStream *)&SDU1, commands }; @@ -98,9 +97,9 @@ static THD_FUNCTION(Thread1, arg) { systime_t time; time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500; - palClearLine(PORTAB_BLINK_LED1); + palClearLine(LINE_LED_RED); chThdSleepMilliseconds(time); - palSetLine(PORTAB_BLINK_LED1); + palSetLine(LINE_LED_RED); chThdSleepMilliseconds(time); } } @@ -120,16 +119,11 @@ int main(void) { halInit(); chSysInit(); - /* - * Board-dependent initialization. - */ - portab_setup(); - /* * Initializes a serial-over-USB CDC driver. */ - sduObjectInit(&PORTAB_SDU1); - sduStart(&PORTAB_SDU1, &serusbcfg); + sduObjectInit(&SDU1); + sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. @@ -155,7 +149,7 @@ int main(void) { * Normal main() thread activity, spawning shells. */ while (true) { - if (PORTAB_SDU1.config->usbp->state == USB_ACTIVE) { + if (SDU1.config->usbp->state == USB_ACTIVE) { thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO + 1, shellThread, (void *)&shell_cfg1); diff --git a/source/usbcfg.c b/source/usbcfg.c index 6487b6a..e757238 100644 --- a/source/usbcfg.c +++ b/source/usbcfg.c @@ -18,7 +18,7 @@ #include "portab.h" /* Virtual serial port over USB.*/ -SerialUSBDriver PORTAB_SDU1; +SerialUSBDriver SDU1; /* * Endpoints to be used for USBD1. @@ -265,7 +265,7 @@ static const USBEndpointConfig ep2config = { * Handles the USB driver global events. */ static void usb_event(USBDriver *usbp, usbevent_t event) { - extern SerialUSBDriver PORTAB_SDU1; + extern SerialUSBDriver SDU1; switch (event) { case USB_EVENT_ADDRESS: @@ -280,7 +280,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { usbInitEndpointI(usbp, USB1_INTERRUPT_REQUEST_EP, &ep2config); /* Resetting the state of the CDC subsystem.*/ - sduConfigureHookI(&PORTAB_SDU1); + sduConfigureHookI(&SDU1); chSysUnlockFromISR(); return; @@ -292,7 +292,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Disconnection event on suspend.*/ - sduSuspendHookI(&PORTAB_SDU1); + sduSuspendHookI(&SDU1); chSysUnlockFromISR(); return; @@ -300,7 +300,7 @@ static void usb_event(USBDriver *usbp, usbevent_t event) { chSysLockFromISR(); /* Connection event on wakeup.*/ - sduWakeupHookI(&PORTAB_SDU1); + sduWakeupHookI(&SDU1); chSysUnlockFromISR(); return; @@ -318,7 +318,7 @@ static void sof_handler(USBDriver *usbp) { (void)usbp; osalSysLockFromISR(); - sduSOFHookI(&PORTAB_SDU1); + sduSOFHookI(&SDU1); osalSysUnlockFromISR(); } @@ -336,7 +336,7 @@ const USBConfig usbcfg = { * Serial over USB driver configuration. */ const SerialUSBConfig serusbcfg = { - &PORTAB_USB1, + &USBD1, USB1_DATA_REQUEST_EP, USB1_DATA_AVAILABLE_EP, USB1_INTERRUPT_REQUEST_EP diff --git a/source/usbcfg.h b/source/usbcfg.h index a739ad7..7f2e941 100644 --- a/source/usbcfg.h +++ b/source/usbcfg.h @@ -19,7 +19,7 @@ extern const USBConfig usbcfg; extern SerialUSBConfig serusbcfg; -extern SerialUSBDriver PORTAB_SDU1; +extern SerialUSBDriver SDU1; #endif /* USBCFG_H */