X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Fstm32p103%2Fmain.c;h=483852e2148263abc988f5ca505c9402424687c0;hb=391b4f8d9c82c413f2cd11fb3ba3aeb311f62184;hp=83481f8c00ac6ab037d663b2939531f00da78abf;hpb=5e73dc4833ec0d8d10a03083fca31be9dcb55901;p=bertos.git diff --git a/examples/stm32p103/main.c b/examples/stm32p103/main.c index 83481f8c..483852e2 100644 --- a/examples/stm32p103/main.c +++ b/examples/stm32p103/main.c @@ -43,25 +43,40 @@ #define LED_PIN (1 << 12) -int main(void) +static void led_init(void) { - IRQ_ENABLE; - timer_init(); - - /* Enable clocking on RCC APB2 */ - RCC->AHBENR |= 1; /* Enable clocking on GPIOA and GPIOC */ - RCC->APB2ENR |= RCC_APB2_GPIOA | RCC_APB2_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); - while(1) +} + +static void NORETURN led_process(void) +{ + int i; + + for (i = 0; ; i = !i) { - ticks_t clock = timer_clock_unlocked(); + stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, i); + timer_delay(250); + } +} + +int main(void) +{ + int i; - if (clock & 0x10) - stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, 1); - else - stm32_gpioPinWrite((struct stm32_gpio *)GPIOC_BASE, LED_PIN, 0); + IRQ_ENABLE; + kdbg_init(); + timer_init(); + proc_init(); + led_init(); + + proc_new(led_process, NULL, KERN_MINSTACKSIZE, NULL); + for (i = 0; ; i = !i) + { + kputs("BeRTOS up & running!\n"); + timer_delay(500); } }