diff options
-rw-r--r-- | stm32f091/esp8266.c | 12 | ||||
-rw-r--r-- | stm32f091/esp8266.h | 3 | ||||
-rw-r--r-- | stm32f091/main.c | 6 | ||||
-rw-r--r-- | stm32f091/makefile | 1 | ||||
-rw-r--r-- | stm32f091/setup.c | 1 | ||||
-rw-r--r-- | stm32f091/test.c | 25 | ||||
-rw-r--r-- | stm32f091/test.h | 4 |
7 files changed, 42 insertions, 10 deletions
diff --git a/stm32f091/esp8266.c b/stm32f091/esp8266.c index 341f052..98c4e10 100644 --- a/stm32f091/esp8266.c +++ b/stm32f091/esp8266.c @@ -14,6 +14,7 @@ int isOK = 0; // TODO: remove uint16_t g_ws_esp8266_dma_old_pos = 0; uint16_t g_ws_esp8266_dma_new_pos = 0; +/* // when rx receives data handle the message. this function is in stm32. this name needs to stay the same or else it wont work. void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){ if(huart->Instance == USART1) { @@ -51,14 +52,11 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){ } } } +*/ -void DMA1_Ch1_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_usart1_rx); -} - -void DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler(void) { - HAL_DMA_IRQHandler(&hdma_usart1_tx); -} +void DMA1_Ch1_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_usart1_rx); } +void DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler(void) { HAL_DMA_IRQHandler(&hdma_usart1_tx); } +void USART1_IRQHandler(void) { HAL_UART_IRQHandler(&huart1); } void ws_esp8266_ATsendCommand(uint8_t* data){ char dataChar[20]; diff --git a/stm32f091/esp8266.h b/stm32f091/esp8266.h index 9df02cb..d18c214 100644 --- a/stm32f091/esp8266.h +++ b/stm32f091/esp8266.h @@ -6,11 +6,12 @@ extern char g_ws_esp8266_dma_rx_buffer[WS_DMA_RX_BUFFER_SIZE]; -void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *, uint16_t); +// void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *, uint16_t); /** @brief This function handles DMA1 channel 2 to 3 and DMA2 channel 1 to 2 interrupts. */ void DMA1_Ch2_3_DMA2_Ch1_2_IRQHandler(void); /** @brief This function handles DMA1 channel 1 interrupt. */ void DMA1_Ch1_IRQHandler(void); +void USART1_IRQHandler(void); void ws_esp8266_ATsendCommand(uint8_t* data); int ws_esp8266_checkOK(uint8_t *receiveData,int length); diff --git a/stm32f091/main.c b/stm32f091/main.c index ed0dacd..f5fe563 100644 --- a/stm32f091/main.c +++ b/stm32f091/main.c @@ -6,8 +6,12 @@ #include "setup.h" #include "sensor.h" +#include "test.h" + int main() { ws_io_setup(); - xTaskCreate(ws_sensor_read_task, "sensor", 128, NULL, 1, NULL); + // xTaskCreate(ws_sensor_read_task, "sensor", 64, NULL, 1, NULL); + xTaskCreate(ws_test_write_task, "testw", 16, NULL, 2, NULL); + xTaskCreate(ws_test_read_task, "testr", 16, NULL, 2, NULL); vTaskStartScheduler(); } diff --git a/stm32f091/makefile b/stm32f091/makefile index 20424c3..bf20f00 100644 --- a/stm32f091/makefile +++ b/stm32f091/makefile @@ -90,6 +90,7 @@ $(TARGET).elf: $(OBJS) flash: $(TARGET).bin st-flash write $(TARGET).bin 0x08000000 + st-flash reset compile_commands: clean compiledb make -n diff --git a/stm32f091/setup.c b/stm32f091/setup.c index 63efd37..39cff07 100644 --- a/stm32f091/setup.c +++ b/stm32f091/setup.c @@ -132,7 +132,6 @@ static void ws_io_usart1_setup() { if (HAL_UART_Init(&huart1) != HAL_OK) return ws_setup_error_handler(); - HAL_UART_Receive_DMA(&huart1, (uint8_t*) g_ws_esp8266_dma_rx_buffer, WS_DMA_RX_BUFFER_SIZE); __HAL_DMA_DISABLE_IT(&hdma_usart1_rx, DMA_IT_HT); } diff --git a/stm32f091/test.c b/stm32f091/test.c new file mode 100644 index 0000000..4d1b936 --- /dev/null +++ b/stm32f091/test.c @@ -0,0 +1,25 @@ +#include <stm32f0xx_hal.h> +#include <FreeRTOS.h> +#include <task.h> + +#include "setup.h" + +uint8_t tx_buffer[] = "AT\r\n"; + +void ws_test_read_task() { + uint8_t* buf; // TODO: not working + while (1) { + HAL_UART_Receive_DMA(&huart1, buf, 1); + HAL_UART_Transmit(&huart2, buf, 1, 100); + } +} + +void ws_test_write_task() { + while (1) { + HAL_UART_Transmit_DMA(&huart1, tx_buffer, sizeof(tx_buffer)); + __HAL_UART_ENABLE_IT(&huart1, UART_IT_TXE); + + HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); + vTaskDelay(portTICK_PERIOD_MS * 1000 * 1); + } +} diff --git a/stm32f091/test.h b/stm32f091/test.h new file mode 100644 index 0000000..6c312d9 --- /dev/null +++ b/stm32f091/test.h @@ -0,0 +1,4 @@ +#pragma once + +void ws_test_read_task(); +void ws_test_write_task(); |