From 3c592b5f11e2319fdf00036bd4943dc522dbaa17 Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 21 Apr 2020 14:28:26 +0800 Subject: [PATCH] TencentOS tiny EVB_MX & Sipeed Longan nano support nrf24l01 --- .../eclipse/nRF24L01/nrf24.c | 4 +- .../eclipse/nRF24L01/nrf24l01_gd32v_hal.c | 6 +- .../STM32CubeIDE/nRF24L01/.cproject | 597 ++++++++++++------ .../STM32CubeIDE/nRF24L01/.project | 5 + .../STM32CubeIDE/nRF24L01/Inc/main.h | 5 +- .../STM32CubeIDE/nRF24L01/Inc/stm32l4xx_it.h | 1 + .../STM32CubeIDE/nRF24L01/Src/main.c | 59 +- .../STM32CubeIDE/nRF24L01/Src/nrf24.c | 179 ++++++ .../STM32CubeIDE/nRF24L01/Src/nrf24l01.c | 5 +- .../Src/{nrf24l01.h => nrf24l01.old.h} | 2 + .../STM32CubeIDE/nRF24L01/Src/nrf24l01_hal | 0 .../STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.c | 5 +- .../STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.h | 2 + .../nRF24L01/Src/nrf24l01_stm32_hal.c | 33 + .../nRF24L01/Src/nrf24l01_stm32_hal.h | 29 + .../STM32CubeIDE/nRF24L01/Src/stm32l4xx_it.c | 17 + .../STM32CubeIDE/nRF24L01/nRF24L01.ioc | 20 +- 17 files changed, 713 insertions(+), 256 deletions(-) create mode 100644 board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24.c rename board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/{nrf24l01.h => nrf24l01.old.h} (99%) delete mode 100644 board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal create mode 100644 board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.c create mode 100644 board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.h diff --git a/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24.c b/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24.c index 75218f4b..2d7ed718 100644 --- a/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24.c +++ b/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24.c @@ -272,10 +272,10 @@ void test_nrf24l01_tx() { nrf_set_standby_mode(); nrf_set_send_mode(); nrf_disable_tx_irq(); - nrf_set_rf_channel(100); + nrf_set_rf_channel(64); nrf_set_datarate(NRF_2Mbps); nrf_enable_dynamic_payload(0); - uint8_t txaddr[] = { 0xCB, 0xA7, 0xF9, 0xAC, 0xE1 }; + uint8_t txaddr[] = { 0xCB, 0xA7, 0xF9, 0xAC, 0xE0 }; nrf_set_txaddr(txaddr, 5); nrf_flush_rx(); diff --git a/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24l01_gd32v_hal.c b/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24l01_gd32v_hal.c index bd040c50..cea66a68 100644 --- a/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24l01_gd32v_hal.c +++ b/board/Sipeed_LonganNano/eclipse/nRF24L01/nrf24l01_gd32v_hal.c @@ -18,13 +18,11 @@ int nrf_hal_init(void *private) { } void nrf_hal_csn(uint8_t mode) { - //gpio_bit_write(g_nrf_hal.csn_port, g_nrf_hal.csn_pin, mode == 0 ? RESET : SET); - mode == 0 ? gpio_bit_reset(g_nrf_hal.csn_port, g_nrf_hal.csn_pin) : gpio_bit_set(g_nrf_hal.csn_port, g_nrf_hal.csn_pin); + gpio_bit_write(g_nrf_hal.csn_port, g_nrf_hal.csn_pin, mode == 0 ? RESET : SET); } void nrf_hal_ce(uint8_t mode) { - //gpio_bit_write(g_nrf_hal.ce_port, g_nrf_hal.ce_pin, mode == 0 ? RESET : SET); - mode == 0 ? gpio_bit_reset(g_nrf_hal.ce_port, g_nrf_hal.ce_pin) : gpio_bit_set(g_nrf_hal.ce_port, g_nrf_hal.ce_pin); + gpio_bit_write(g_nrf_hal.ce_port, g_nrf_hal.ce_pin, mode == 0 ? RESET : SET); } uint8_t _spi_transfer(uint32_t spi, uint8_t data) { diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.cproject b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.cproject index 2e0d717f..f6143169 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.cproject +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.cproject @@ -1,201 +1,402 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.project b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.project index 90d7aa3c..481685a7 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.project +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/.project @@ -33,6 +33,11 @@ 2 virtual:/virtual + + Src/nrf24l01 + 2 + PARENT-4-PROJECT_LOC/devices/nrf24l01 + Src/TencentOS tiny/arch 2 diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/main.h b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/main.h index fb28bc4c..17764300 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/main.h +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/main.h @@ -62,10 +62,11 @@ void Error_Handler(void); #define LED_GPIO_Port GPIOC #define CSN_Pin GPIO_PIN_4 #define CSN_GPIO_Port GPIOA -#define nRF24_IRQ_Pin_Pin GPIO_PIN_14 -#define nRF24_IRQ_Pin_GPIO_Port GPIOB #define CE_Pin GPIO_PIN_9 #define CE_GPIO_Port GPIOC +#define nRF24_IRQ_Pin_Pin GPIO_PIN_8 +#define nRF24_IRQ_Pin_GPIO_Port GPIOA +#define nRF24_IRQ_Pin_EXTI_IRQn EXTI9_5_IRQn /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/stm32l4xx_it.h b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/stm32l4xx_it.h index 7d4fedf6..5fc35ea9 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/stm32l4xx_it.h +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Inc/stm32l4xx_it.h @@ -56,6 +56,7 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); +void EXTI9_5_IRQHandler(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/main.c b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/main.c index ab6803d3..da1c9c31 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/main.c +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/main.c @@ -24,7 +24,6 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "tos_k.h" -#include "nrf24l01.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -34,42 +33,17 @@ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ -#define TASK_SIZE 4096 +#define TASK_SIZE 1024 - -k_task_t task1_handle; k_task_t task2_handle; -uint8_t task1_stk[TASK_SIZE]; uint8_t task2_stk[TASK_SIZE]; -extern uint8_t nrf_received_data; -void task1(void *arg) -{ - int task_cnt1 = 0; - while (1) { - task_cnt1++; - //printf("task1 cnt: %d\n", task_cnt1); -#if 1 - if(0 != nrf_received_data) { - nrf_received_data = 0; - HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); - tos_task_delay(100); - HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); - tos_task_delay(100); - } -#endif - - //HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, task_cnt1 % 2 ? GPIO_PIN_SET : GPIO_PIN_RESET); - tos_task_delay(1); - } -} void task2(void *arg) { int task_cnt2 = 0; - tos_task_delay(200); - nrf_hal_test(); + while (1) { task_cnt2--; printf("task2 cnt: %08x\n", task_cnt2); @@ -114,6 +88,8 @@ PUTCHAR_PROTOTYPE HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, 0xFFFF); return ch; } + +void nrf24l01_init(); /* USER CODE END 0 */ /** @@ -147,19 +123,21 @@ int main(void) MX_USART2_UART_Init(); MX_SPI1_Init(); /* USER CODE BEGIN 2 */ -#if 1 + tos_knl_init(); - tos_task_create(&task1_handle, "task1", task1, NULL, 3, task1_stk, TASK_SIZE, 0); + + nrf24l01_init(); + tos_task_create(&task2_handle, "task2", task2, NULL, 3, task2_stk, TASK_SIZE, 0); + tos_knl_start(); -#endif + /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { - nrf_hal_test(); //HAL_Delay(1000); /* USER CODE END WHILE */ @@ -308,7 +286,6 @@ static void MX_GPIO_Init(void) __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, LED_Pin|CE_Pin, GPIO_PIN_RESET); @@ -330,12 +307,6 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(CSN_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : nRF24_IRQ_Pin_Pin */ - GPIO_InitStruct.Pin = nRF24_IRQ_Pin_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(nRF24_IRQ_Pin_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pin : CE_Pin */ GPIO_InitStruct.Pin = CE_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; @@ -343,6 +314,16 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(CE_GPIO_Port, &GPIO_InitStruct); + /*Configure GPIO pin : nRF24_IRQ_Pin_Pin */ + GPIO_InitStruct.Pin = nRF24_IRQ_Pin_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; + GPIO_InitStruct.Pull = GPIO_PULLUP; + HAL_GPIO_Init(nRF24_IRQ_Pin_GPIO_Port, &GPIO_InitStruct); + + /* EXTI interrupt init*/ + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + } /* USER CODE BEGIN 4 */ diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24.c b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24.c new file mode 100644 index 00000000..d16499cb --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24.c @@ -0,0 +1,179 @@ +#include "tos_k.h" +#include +#include "stdlib.h" +#include "nrf24l01_stm32_hal.h" +#include "stm32l4xx_hal.h" +#include "main.h" + +extern SPI_HandleTypeDef hspi1; + +extern k_sem_t sem_led; +k_sem_t sem_nrf; + +#define TASK_SIZE (8*1024) +k_task_t task_nrf24_handle; +uint8_t task_nrf24_stk[TASK_SIZE]; + +#define LED_TASK_SIZE 1024 +k_task_t led_handle; +uint8_t led_stk[LED_TASK_SIZE]; + +void task_nrf24(); + +k_sem_t sem_led; + +void task_led(void *arg) +{ + while (1) { + tos_sem_pend(&sem_led, ~0); + HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_SET); + tos_task_delay(50); + HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET); + } +} + + + +void nrf24l01_init() { + { + nrf_hal_init_t nhi; + nhi.spi = &hspi1; + nhi.ce_port = CE_GPIO_Port; + nhi.ce_pin = CE_Pin; + nhi.csn_port= CSN_GPIO_Port; + nhi.csn_pin = CSN_Pin; + + nrf_init_t ni = { + .init = nrf_hal_init, + .ce = nrf_hal_ce, + .csn = nrf_hal_csn, + .spi_recv = nrf_hal_spi_recv, + .spi_send = nrf_hal_spi_send, + .private = &nhi, + }; + + nrf_init(&ni); + } + + + tos_sem_create(&sem_nrf, 1); + tos_sem_create(&sem_led, 1); + tos_task_create(&task_nrf24_handle, "task_nrf24", task_nrf24, NULL, 5, task_nrf24_stk, TASK_SIZE, 0); + tos_task_create(&led_handle, "led", task_led, NULL, 6, led_stk, LED_TASK_SIZE, 0); +} + +void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) +{ + if(GPIO_PIN_8 != GPIO_Pin) { + return; + } + + uint8_t status = 0; + nrf_read_reg_byte(REG_STATUS, &status); + + if(status & _BV(RX_DR)) { + tos_sem_post(&sem_nrf); + } +} + +#define ADDRLEN 5 +void print_rxaddr(uint8_t pipe) { + uint8_t addr[ADDRLEN]; + + uint8_t addrlen = ADDRLEN; + nrf_get_rxaddr(pipe, addr, &addrlen); + + printf("pipe %u addr: ", pipe); + for(int i=0; i #include "tos_k.h" @@ -381,3 +383,4 @@ uint8_t nrf_hal_test() { //return nrf_hal_test_rx(); return nrf_hal_test_tx(); } +#endif diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.h b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.old.h similarity index 99% rename from board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.h rename to board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.old.h index 95fc481e..03dc8940 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.h +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01.old.h @@ -1,3 +1,4 @@ +#if 0 #ifndef NRF24L01_H_ #define NRF24L01_H_ @@ -285,3 +286,4 @@ uint8_t nrf_hal_test(); #endif /* NRF24L01_H_ */ +#endif diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal deleted file mode 100644 index e69de29b..00000000 diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.c b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.c index 500ecb92..0c5410f6 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.c +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.c @@ -1,4 +1,6 @@ -#include "nrf24l01.h" + +#if 0 +#include static SPI_HandleTypeDef *nrf_spi; static GPIO_TypeDef* nrf_csn_gpio_port; @@ -154,3 +156,4 @@ int nrf_hal_write_cmd(uint8_t cmd) { return 0; } +#endif diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.h b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.h index df4c67a1..f97c55d9 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.h +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_hal.h @@ -1,3 +1,4 @@ +#if 0 #ifndef NRF24L01_HAL_H_ #define NRF24L01_HAL_H_ @@ -38,3 +39,4 @@ int nrf_hal_write_cmd(uint8_t cmd); #endif /* NRF24L01_HAL_H_ */ +#endif diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.c b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.c new file mode 100644 index 00000000..a56abd55 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.c @@ -0,0 +1,33 @@ +#include "nrf24l01_stm32_hal.h" +#include + +static nrf_hal_init_t g_nrf_hal; + +int nrf_hal_init(void *private) { + + memcpy(&g_nrf_hal, private, sizeof(nrf_hal_init_t)); + + nrf_hal_ce(1); + nrf_hal_csn(1); + + return 0; +} + +void nrf_hal_csn(uint8_t mode) { + HAL_GPIO_WritePin(g_nrf_hal.csn_port, g_nrf_hal.csn_pin, mode == 0 ? GPIO_PIN_RESET : GPIO_PIN_SET); +} + +void nrf_hal_ce(uint8_t mode) { + HAL_GPIO_WritePin(g_nrf_hal.ce_port, g_nrf_hal.ce_pin, mode == 0 ? GPIO_PIN_RESET : GPIO_PIN_SET); +} + +void nrf_hal_spi_send(uint8_t *buf, uint8_t len) { + HAL_SPI_Transmit(g_nrf_hal.spi, buf, len, HAL_MAX_DELAY); + +} + +void nrf_hal_spi_recv(uint8_t *buf, uint8_t len) { + + HAL_SPI_Receive(g_nrf_hal.spi, buf, len, HAL_MAX_DELAY); + +} diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.h b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.h new file mode 100644 index 00000000..c3f43919 --- /dev/null +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/nrf24l01_stm32_hal.h @@ -0,0 +1,29 @@ +#ifndef NRF24L01_STM32_HAL_H_ +#define NRF24L01_STM32_HAL_H_ + +#include + +#ifdef STM32L431xx +#include "stm32l4xx_hal.h" +#endif + +typedef struct { + SPI_HandleTypeDef *spi; + GPIO_TypeDef* csn_port; + uint16_t csn_pin; + GPIO_TypeDef* ce_port; + uint16_t ce_pin; +} nrf_hal_init_t; + +int nrf_hal_init(void *nhi); + +void nrf_hal_csn(uint8_t mode); + +void nrf_hal_ce(uint8_t mode); + +void nrf_hal_spi_send(uint8_t *buf, uint8_t len); + +void nrf_hal_spi_recv(uint8_t *buf, uint8_t len); + + +#endif /* NRF24L01_STM32_HAL_H_ */ diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/stm32l4xx_it.c b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/stm32l4xx_it.c index 71480477..169406a5 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/stm32l4xx_it.c +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/Src/stm32l4xx_it.c @@ -204,6 +204,23 @@ void SysTick_Handler(void) /* please refer to the startup file (startup_stm32l4xx.s). */ /******************************************************************************/ +/** + * @brief This function handles EXTI line[9:5] interrupts. + */ +void EXTI9_5_IRQHandler(void) +{ + /* USER CODE BEGIN EXTI9_5_IRQn 0 */ + if(tos_knl_is_running()) + { + tos_knl_irq_enter(); + /* USER CODE END EXTI9_5_IRQn 0 */ + HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); + /* USER CODE BEGIN EXTI9_5_IRQn 1 */ + tos_knl_irq_leave(); + } + /* USER CODE END EXTI9_5_IRQn 1 */ +} + /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ diff --git a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/nRF24L01.ioc b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/nRF24L01.ioc index e9a3262a..d1ae67e7 100644 --- a/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/nRF24L01.ioc +++ b/board/TencentOS_tiny_EVB_MX/STM32CubeIDE/nRF24L01/nRF24L01.ioc @@ -1,6 +1,5 @@ #MicroXplorer Configuration settings - do not modify Mcu.Family=STM32L4 -PB14.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING RCC.MSI_VALUE=4000000 RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE ProjectManager.MainLocation=Src @@ -21,9 +20,7 @@ ProjectManager.NoMain=false SPI1.IPParameters=VirtualType,Mode,Direction,DataSize,CalculateBaudRate,BaudRatePrescaler PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PC13.Locked=true -SH.GPXTI14.0=GPIO_EXTI14 PC13.Signal=GPIO_Output -PB14.GPIO_Label=nRF24_IRQ_Pin RCC.PLLSAI1RoutputFreq_Value=32000000 RCC.SWPMI1Freq_Value=80000000 ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_SPI1_Init-SPI1-false-HAL-true @@ -33,7 +30,6 @@ ProjectManager.DefaultFWLocation=true RCC.USART2Freq_Value=80000000 ProjectManager.DeletePrevious=true PC13.GPIO_Label=LED -PB14.Locked=true PinOutPanel.RotationAngle=0 RCC.FamilyName=M RCC.MCO1PinFreq_Value=80000000 @@ -52,6 +48,7 @@ Mcu.IP0=NVIC PA12.Locked=true Mcu.IP1=RCC PA12.Signal=SPI1_MOSI +PA8.GPIO_Label=nRF24_IRQ_Pin PA4.PinState=GPIO_PIN_SET Mcu.UserConstants= RCC.VCOSAI1OutputFreq_Value=64000000 @@ -64,9 +61,10 @@ Mcu.IPNb=5 ProjectManager.PreviousToolchain= RCC.APB2TimFreq_Value=80000000 SPI1.CalculateBaudRate=312.5 KBits/s +PA8.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI Mcu.Pin6=PA6 -Mcu.Pin7=PB14 -Mcu.Pin8=PC9 +Mcu.Pin7=PC9 +Mcu.Pin8=PA8 Mcu.Pin9=PA12 RCC.LSE_VALUE=32768 PA1.Signal=SPI1_SCK @@ -80,12 +78,12 @@ Mcu.Pin3=PA2 RCC.USART3Freq_Value=80000000 Mcu.Pin4=PA3 Mcu.Pin5=PA4 -PB14.Signal=GPXTI14 ProjectManager.ProjectBuild=false RCC.HSE_VALUE=8000000 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false PA4.GPIO_PuPd=GPIO_PULLUP +PA8.Locked=true board=custom PA4.Locked=true USART2.VirtualMode-Asynchronous=VM_ASYNC @@ -110,6 +108,7 @@ SPI1.DataSize=SPI_DATASIZE_8BIT File.Version=6 VP_SYS_VS_Systick.Mode=SysTick PC13.GPIO_PuPd=GPIO_PULLDOWN +PA8.Signal=GPXTI8 NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false RCC.PLLRCLKFreq_Value=80000000 PA4.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label @@ -133,18 +132,21 @@ PA6.Signal=SPI1_MISO PA12.Mode=Full_Duplex_Master NVIC.ForceEnableDMAVector=true KeepUserPlacement=false +PA8.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING +SH.GPXTI8.0=GPIO_EXTI8 NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false ProjectManager.CompilerOptimize=6 ProjectManager.ToolChainLocation= RCC.LSI_VALUE=32000 VP_SYS_VS_Systick.Signal=SYS_VS_Systick +NVIC.EXTI9_5_IRQn=true\:0\:0\:false\:false\:true\:true\:true +SH.GPXTI8.ConfNb=1 RCC.LSCOPinFreq_Value=32000 ProjectManager.HeapSize=0x200 NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false -PB14.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI ProjectManager.ComputerToolchain=false RCC.HSI_VALUE=16000000 -SH.GPXTI14.ConfNb=1 +PA8.GPIO_PuPd=GPIO_PULLUP NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 Mcu.Pin11=PA14 (JTCK-SWCLK) Mcu.Pin12=VP_SYS_VS_Systick