From: arighi Date: Wed, 12 May 2010 12:17:13 +0000 (+0000) Subject: stm32p103: update "blinky" example using timer_delay(). X-Git-Tag: 2.5.0~255 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=660d3a3e0f7129ed821a2ba44473254eaea728ce;p=bertos.git stm32p103: update "blinky" example using timer_delay(). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3662 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/examples/stm32p103/main.c b/examples/stm32p103/main.c index 83481f8c..4ca8ea3c 100644 --- a/examples/stm32p103/main.c +++ b/examples/stm32p103/main.c @@ -43,25 +43,29 @@ #define LED_PIN (1 << 12) +static void led_init(void) +{ + /* Enable clocking on GPIOA and GPIOC */ + RCC->APB2ENR |= RCC_APB2_GPIOC; + /* Configure the LED pin as GPIO */ + stm32_gpioPinConfig((struct stm32_gpio *)GPIOC_BASE, + LED_PIN, GPIO_MODE_OUT_PP, GPIO_SPEED_50MHZ); +} + int main(void) { + int i; + IRQ_ENABLE; + kdbg_init(); timer_init(); + proc_init(); + led_init(); - /* Enable clocking on RCC APB2 */ - RCC->AHBENR |= 1; - /* Enable clocking on GPIOA and GPIOC */ - RCC->APB2ENR |= RCC_APB2_GPIOA | RCC_APB2_GPIOC; - - stm32_gpioPinConfig((struct stm32_gpio *)GPIOC_BASE, - LED_PIN, GPIO_MODE_OUT_PP, GPIO_SPEED_50MHZ); - while(1) + for (i = 0; ; i = !i) { - ticks_t clock = timer_clock_unlocked(); - - if (clock & 0x10) - stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, 1); - else - stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, 0); + stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, i); + kputs("hello world\n"); + timer_delay(500); } } diff --git a/examples/stm32p103/stm32p103.mk b/examples/stm32p103/stm32p103.mk index c13c4fc6..555b9af4 100644 --- a/examples/stm32p103/stm32p103.mk +++ b/examples/stm32p103/stm32p103.mk @@ -5,7 +5,7 @@ # Author: Andrea Righi # Set to 1 for debug builds -stm32p103_DEBUG = 0 +stm32p103_DEBUG = 1 include bertos/fonts/fonts.mk @@ -13,8 +13,16 @@ include bertos/fonts/fonts.mk TRG += stm32p103 stm32p103_CSRC = \ + bertos/mware/formatwr.c \ + bertos/mware/hex.c \ + bertos/mware/sprintf.c \ + bertos/mware/event.c \ + bertos/struct/heap.c \ + bertos/kern/signal.c \ + bertos/kern/monitor.c \ bertos/kern/proc.c \ bertos/drv/timer.c \ + bertos/cpu/cortex-m3/drv/kdebug_stm32.c \ bertos/cpu/cortex-m3/drv/gpio_stm32.c \ bertos/cpu/cortex-m3/drv/clock_stm32.c \ bertos/cpu/cortex-m3/drv/timer_cm3.c \