void target_early_init(void) { GPIO_InitTypeDef gpio_init; __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOJ_CLK_ENABLE(); #if DEBUG_UART == 3 // configure usart 3 pins. gpio_config(GPIO_USART3_TX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP); gpio_config(GPIO_USART3_RX, GPIO_STM32_AF | GPIO_STM32_AFn(GPIO_AF7_USART3) | GPIO_PULLUP); #else #error need to configure gpio pins for debug uart #endif gpio_init.Mode = GPIO_MODE_OUTPUT_PP; gpio_init.Pull = GPIO_NOPULL; gpio_init.Speed = GPIO_SPEED_LOW; gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED108) | GPIO_TO_PIN_MASK(GPIO_LED109) | GPIO_TO_PIN_MASK(GPIO_LED110) | GPIO_TO_PIN_MASK(GPIO_LED111); HAL_GPIO_Init(GPIOE, &gpio_init); gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED112) | GPIO_TO_PIN_MASK(GPIO_LED113); HAL_GPIO_Init(GPIOD, &gpio_init); gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_LED114) | GPIO_TO_PIN_MASK(GPIO_LED115); HAL_GPIO_Init(GPIOJ, &gpio_init); // Initialize the switches GPIOs for interrupt on raising edge. In order // to use stm32_EXTI15_10_IRQ() handler needs to be provided and EXTI15_10_IRQn // needs to be enabled. gpio_init.Mode = GPIO_MODE_INPUT; gpio_init.Pull = GPIO_NOPULL; gpio_init.Speed = GPIO_SPEED_FAST; gpio_init.Mode = GPIO_MODE_IT_RISING; gpio_init.Pin = GPIO_TO_PIN_MASK(GPIO_SW100) | GPIO_TO_PIN_MASK(GPIO_SW101) | GPIO_TO_PIN_MASK(GPIO_SW102) | GPIO_TO_PIN_MASK(GPIO_SW103); HAL_GPIO_Init(GPIOJ, &gpio_init); #if ENABLE_SENSORBUS // Initialize Sensor bus (accelerometer / gyroscope / nrf51 spi bus sensor_bus_init_early(); #endif // now that the uart gpios are configured, enable the debug uart. stm32_debug_early_init(); // default all the debug leds to off target_set_debug_led(0, false); target_set_debug_led(1, false); target_set_debug_led(2, false); target_set_debug_led(3, false); }
void arm_cm_irq_exit(bool reschedule) { target_set_debug_led(1, false); if (reschedule) arm_cm_trigger_preempt(); KEVLOG_IRQ_EXIT(__get_IPSR()); __enable_irq(); // clear PRIMASK }
void arm_cm_irq_entry(void) { // Set PRIMASK to 1 // This is so that later calls to arch_ints_disabled() returns true while we're inside the int handler // Note: this will probably screw up future efforts to stack higher priority interrupts since we're setting // the cpu to essentially max interrupt priority here. Will have to rethink it then. __disable_irq(); THREAD_STATS_INC(interrupts); KEVLOG_IRQ_ENTER(__get_IPSR()); target_set_debug_led(1, true); }