You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "port.h"
#include <stdint.h>
#include <stdio.h>
#include "main.h"
// #include "modbus_processer.h"
#include "tim.h"
#include "usart.h"
//
#include "../../../iflytop_microcontroller/sdk/stm32/pwm.h"
#include "../../../iflytop_microcontroller/sdk/stm32/stm32sdk.h"
/**********************************************************************************************************************
* ===================================================printf重定向=================================================== * **********************************************************************************************************************/ int fputc(int ch, FILE* stream) { uint8_t c = ch; HAL_UART_Transmit(&DEBUG_UART, &c, 1, 100); return ch; } /***********************************************************************************************************************
* ====================================================调试指示灯===================================================== * ***********************************************************************************************************************/ void port_do_debug_light_state(void) { static uint32_t lastprocess = 0; if (sys_haspassedms(lastprocess) > 300) { lastprocess = HAL_GetTick(); HAL_GPIO_TogglePin(DEBUG_LIGHT_PORT, DEBUG_LIGHT_PIN); } } /***********************************************************************************************************************
* =====================================================串口相关====================================================== * ***********************************************************************************************************************/
static uart_t m_uarts[] = { {&DEBUG_UART, 0}, // {&MODBUS_UART, 0},
}; __weak void port_mock_on_uart_rx(uart_t* uart) {} static void uarts_start_receive(uart_t* uart) { HAL_UART_Receive_IT(uart->uarthandler, &uart->rxbuf, 1); } void HAL_UART_RxCpltCallback(UART_HandleTypeDef* huart) { for (size_t i = 0; i < sizeof(m_uarts) / sizeof(uart_t); i++) { if (m_uarts[i].uarthandler == huart) { port_mock_on_uart_rx(&m_uarts[i]); uarts_start_receive(&m_uarts[i]); return; } } } void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart) { for (size_t i = 0; i < sizeof(m_uarts) / sizeof(uart_t); i++) { if (m_uarts[i].uarthandler == huart) { uarts_start_receive(&m_uarts[i]); return; } } } // export
void port_uart_start_all_uart_receive(void) { for (size_t i = 0; i < sizeof(m_uarts) / sizeof(uart_t); i++) { uarts_start_receive(&m_uarts[i]); } }
bool port_electric_relay_get_state(int relayindex) { /*
example: if (relayindex == 1) { return GPIO_GET(C, 8, !!); } */
return false; } void port_electric_relay_set_state(int relayindex, bool state) { /*
example: if (relayindex == 1) { GPIO_SET(C, 8, !!, state); } */ }
|