12 changed files with 5947 additions and 301 deletions
-
0README.md
-
105app/Core/Src/main.c
-
48app/MDK-ARM/DebugConfig/app_STM32F407ZGTx.dbgconf
-
21app/MDK-ARM/RTE/_app/RTE_Components.h
-
1887app/MDK-ARM/app.uvguix.29643
-
1915app/MDK-ARM/app.uvoptx
-
173app/MDK-ARM/app.uvprojx
-
1960app/MDK-ARM/startup_stm32f407xx.lst
-
79src/port.c
-
29src/port.h
-
17src/usermain.c
-
14src/zboard.h
@ -0,0 +1,48 @@ |
|||||
|
// File: STM32F405_415_407_417_427_437_429_439.dbgconf |
||||
|
// Version: 1.0.0 |
||||
|
// Note: refer to STM32F405/415 STM32F407/417 STM32F427/437 STM32F429/439 reference manual (RM0090) |
||||
|
// refer to STM32F40x STM32F41x datasheets |
||||
|
// refer to STM32F42x STM32F43x datasheets |
||||
|
|
||||
|
// <<< Use Configuration Wizard in Context Menu >>> |
||||
|
|
||||
|
// <h> Debug MCU configuration register (DBGMCU_CR) |
||||
|
// <o.2> DBG_STANDBY <i> Debug Standby Mode |
||||
|
// <o.1> DBG_STOP <i> Debug Stop Mode |
||||
|
// <o.0> DBG_SLEEP <i> Debug Sleep Mode |
||||
|
// </h> |
||||
|
DbgMCU_CR = 0x00000007; |
||||
|
|
||||
|
// <h> Debug MCU APB1 freeze register (DBGMCU_APB1_FZ) |
||||
|
// <i> Reserved bits must be kept at reset value |
||||
|
// <o.26> DBG_CAN2_STOP <i> CAN2 stopped when core is halted |
||||
|
// <o.25> DBG_CAN1_STOP <i> CAN2 stopped when core is halted |
||||
|
// <o.23> DBG_I2C3_SMBUS_TIMEOUT <i> I2C3 SMBUS timeout mode stopped when core is halted |
||||
|
// <o.22> DBG_I2C2_SMBUS_TIMEOUT <i> I2C2 SMBUS timeout mode stopped when core is halted |
||||
|
// <o.21> DBG_I2C1_SMBUS_TIMEOUT <i> I2C1 SMBUS timeout mode stopped when core is halted |
||||
|
// <o.12> DBG_IWDG_STOP <i> Independent watchdog stopped when core is halted |
||||
|
// <o.11> DBG_WWDG_STOP <i> Window watchdog stopped when core is halted |
||||
|
// <o.10> DBG_RTC_STOP <i> RTC stopped when core is halted |
||||
|
// <o.8> DBG_TIM14_STOP <i> TIM14 counter stopped when core is halted |
||||
|
// <o.7> DBG_TIM13_STOP <i> TIM13 counter stopped when core is halted |
||||
|
// <o.6> DBG_TIM12_STOP <i> TIM12 counter stopped when core is halted |
||||
|
// <o.5> DBG_TIM7_STOP <i> TIM7 counter stopped when core is halted |
||||
|
// <o.4> DBG_TIM6_STOP <i> TIM6 counter stopped when core is halted |
||||
|
// <o.3> DBG_TIM5_STOP <i> TIM5 counter stopped when core is halted |
||||
|
// <o.2> DBG_TIM4_STOP <i> TIM4 counter stopped when core is halted |
||||
|
// <o.1> DBG_TIM3_STOP <i> TIM3 counter stopped when core is halted |
||||
|
// <o.0> DBG_TIM2_STOP <i> TIM2 counter stopped when core is halted |
||||
|
// </h> |
||||
|
DbgMCU_APB1_Fz = 0x00000000; |
||||
|
|
||||
|
// <h> Debug MCU APB2 freeze register (DBGMCU_APB2_FZ) |
||||
|
// <i> Reserved bits must be kept at reset value |
||||
|
// <o.18> DBG_TIM11_STOP <i> TIM11 counter stopped when core is halted |
||||
|
// <o.17> DBG_TIM10_STOP <i> TIM10 counter stopped when core is halted |
||||
|
// <o.16> DBG_TIM9_STOP <i> TIM9 counter stopped when core is halted |
||||
|
// <o.1> DBG_TIM8_STOP <i> TIM8 counter stopped when core is halted |
||||
|
// <o.0> DBG_TIM1_STOP <i> TIM1 counter stopped when core is halted |
||||
|
// </h> |
||||
|
DbgMCU_APB2_Fz = 0x00000000; |
||||
|
|
||||
|
// <<< end of configuration section >>> |
@ -0,0 +1,21 @@ |
|||||
|
|
||||
|
/* |
||||
|
* Auto generated Run-Time-Environment Configuration File |
||||
|
* *** Do not modify ! *** |
||||
|
* |
||||
|
* Project: 'app' |
||||
|
* Target: 'app' |
||||
|
*/ |
||||
|
|
||||
|
#ifndef RTE_COMPONENTS_H |
||||
|
#define RTE_COMPONENTS_H |
||||
|
|
||||
|
|
||||
|
/* |
||||
|
* Define the Device Header File: |
||||
|
*/ |
||||
|
#define CMSIS_device_header "stm32f4xx.h" |
||||
|
|
||||
|
|
||||
|
|
||||
|
#endif /* RTE_COMPONENTS_H */ |
1887
app/MDK-ARM/app.uvguix.29643
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1915
app/MDK-ARM/app.uvoptx
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
1960
app/MDK-ARM/startup_stm32f407xx.lst
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,79 @@ |
|||||
|
// #include "port.h" |
||||
|
// #include <stdint.h> |
||||
|
// #include <stdio.h> |
||||
|
// #include "main.h" |
||||
|
// // #include "modbus_processer.h" |
||||
|
// #include "port.h" |
||||
|
// // #include "tim.h" |
||||
|
// #include "usart.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); |
||||
|
// } |
||||
|
// */ |
||||
|
// } |
@ -0,0 +1,29 @@ |
|||||
|
// #pragma once |
||||
|
// #include <stdbool.h> |
||||
|
// #include <stdint.h> |
||||
|
// #include <stdio.h> |
||||
|
// // #include "tim.h" |
||||
|
// #include "usart.h" |
||||
|
// #include "zboard.h" |
||||
|
// #define GPIO_SET(port, pin, mirror, _state) \ |
||||
|
// HAL_GPIO_WritePin(GPIO##port, GPIO_PIN_##pin, mirror _state ? GPIO_PIN_SET : GPIO_PIN_RESET); |
||||
|
// #define GPIO_GET(port, pin, mirror) (mirror(HAL_GPIO_ReadPin(GPIO##port, GPIO_PIN_##pin) == GPIO_PIN_SET)) |
||||
|
// /*********************************************************************************************************************** |
||||
|
// * ====================================================调试指示灯===================================================== * |
||||
|
// ***********************************************************************************************************************/ |
||||
|
// void port_do_debug_light_state(void); |
||||
|
|
||||
|
// /*********************************************************************************************************************** |
||||
|
// * =======================================================UART======================================================== * |
||||
|
// ***********************************************************************************************************************/ |
||||
|
// typedef struct { |
||||
|
// UART_HandleTypeDef* uarthandler; |
||||
|
// uint8_t rxbuf; |
||||
|
// } uart_t; |
||||
|
// void port_mock_on_uart_rx(uart_t* uart); |
||||
|
// void port_uart_start_all_uart_receive(void); |
||||
|
|
||||
|
// bool port_electric_relay_get_state(int relayindex); |
||||
|
// void port_electric_relay_set_state(int relayindex, bool state); |
||||
|
|
||||
|
// static inline bool port_get_gpio_int(int index) { return false; } |
@ -0,0 +1,17 @@ |
|||||
|
#include <stdbool.h> |
||||
|
#include <stdint.h> |
||||
|
#include <stdio.h> |
||||
|
#include <string.h> |
||||
|
|
||||
|
#include "cmsis_os.h" |
||||
|
#include "iwdg.h" |
||||
|
#include "lwip.h" |
||||
|
#include "main.h" |
||||
|
#include "port.h" |
||||
|
#include "usart.h" |
||||
|
|
||||
|
void user_main() { |
||||
|
while (1) { |
||||
|
HAL_IWDG_Refresh(&hiwdg); |
||||
|
} |
||||
|
} |
@ -0,0 +1,14 @@ |
|||||
|
#pragma once |
||||
|
#define VERSION_MAIN_ID 1 |
||||
|
#define VERSION_SUB_ID 1 |
||||
|
|
||||
|
/*********************************************************************************************************************** |
||||
|
* =======================================================DEBUG======================================================= * |
||||
|
***********************************************************************************************************************/ |
||||
|
#define DEBUG_UART huart1 //直接使用指令串口作为调试串口 |
||||
|
#define DEBUG_LIGHT_PORT GPIOB |
||||
|
#define DEBUG_LIGHT_PIN GPIO_PIN_5 |
||||
|
/*********************************************************************************************************************** |
||||
|
* ======================================================微秒定时器=================================================== |
||||
|
***********************************************************************************************************************/ |
||||
|
#define US_TIMER htim4 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue