添加adc,串口,gpio,flash等外设
This commit is contained in:
parent
f3f0b57625
commit
303494d1e4
|
@ -0,0 +1,7 @@
|
||||||
|
#
|
||||||
|
|
||||||
|
obj/
|
||||||
|
|
||||||
|
*.o
|
||||||
|
*.elf
|
||||||
|
*.hex
|
|
@ -109,6 +109,8 @@
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/hardwareDriver/Inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/hardwareDriver/Inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools/RingQueue}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools/RingQueue}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/functionalModule/Inc}""/>
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths.496720673" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths.496720673" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files.1898455566" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files.1898455566" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||||
|
@ -136,6 +138,11 @@
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/GCC/RISC-V}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/GCC/RISC-V}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/MemMang}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS/portable/MemMang}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/hardwareDriver/Inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/tools/RingQueue}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/functionalModule/Inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/App/application/Inc}""/>
|
||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths.2011720354" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths.2011720354" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.systempaths" useByScannerDiscovery="true" valueType="includePath"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.542153928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.542153928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles"/>
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "mrs-debugger",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "CH32V303-FreeRTOS",
|
||||||
|
"cwd": "d:\\psx\\su806\\2.software\\mcu_git\\CH32V303-FreeRTOS",
|
||||||
|
"openOCDCfg": {
|
||||||
|
"useLocalOpenOCD": true,
|
||||||
|
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/openocd.exe",
|
||||||
|
"configOptions": [
|
||||||
|
"-f \"c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/OpenOCD/OpenOCD/bin/wch-riscv.cfg\" -c \"chip_id CH32V30x\""
|
||||||
|
],
|
||||||
|
"gdbport": 3333,
|
||||||
|
"telnetport": 4444,
|
||||||
|
"tclport": 6666,
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 3333,
|
||||||
|
"skipDownloadBeforeDebug": false,
|
||||||
|
"enablePageEraser": false,
|
||||||
|
"enableNoZeroWaitingAreaFlash": false
|
||||||
|
},
|
||||||
|
"gdbCfg": {
|
||||||
|
"executable": "c:/MounRiver/MounRiver_Studio2/resources/app/resources/win32/components/WCH/Toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gdb.exe",
|
||||||
|
"commands": [
|
||||||
|
"set mem inaccessible-by-default off",
|
||||||
|
"set architecture riscv:rv32",
|
||||||
|
"set remotetimeout unlimited",
|
||||||
|
"set disassembler-options xw"
|
||||||
|
],
|
||||||
|
"options": []
|
||||||
|
},
|
||||||
|
"startup": {
|
||||||
|
"initCommands": {
|
||||||
|
"initReset": true,
|
||||||
|
"initResetType": "init",
|
||||||
|
"armSemihosting": false,
|
||||||
|
"additionalCommands": []
|
||||||
|
},
|
||||||
|
"loadedFiles": {
|
||||||
|
"executableFile": "d:\\psx\\su806\\2.software\\mcu_git\\CH32V303-FreeRTOS\\obj\\CH32V303-FreeRTOS.elf",
|
||||||
|
"symbolFile": "d:\\psx\\su806\\2.software\\mcu_git\\CH32V303-FreeRTOS\\obj\\CH32V303-FreeRTOS.elf",
|
||||||
|
"executableFileOffset": 0,
|
||||||
|
"symbolFileOffset": 0
|
||||||
|
},
|
||||||
|
"runCommands": {
|
||||||
|
"runReset": true,
|
||||||
|
"runResetType": "halt",
|
||||||
|
"additionalCommands": [],
|
||||||
|
"setBreakAt": "handle_reset",
|
||||||
|
"continue": true,
|
||||||
|
"setProgramCounterAt": 0
|
||||||
|
},
|
||||||
|
"debugInRAM": false
|
||||||
|
},
|
||||||
|
"svdpath": "c:\\MounRiver\\MounRiver_Studio2\\resources\\app\\resources\\win32\\components\\WCH\\SDK\\default/RISC-V/CH32V307/NoneOS/CH32V307xx.svd",
|
||||||
|
"output": {
|
||||||
|
"showDebugGDBTrace": true,
|
||||||
|
"saveDebugOutputToFile": false,
|
||||||
|
"showDebugOutputTimestamps": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"details": [
|
||||||
|
{
|
||||||
|
"file": "App/hardwareDriver/Inc/HD_GPIO.h",
|
||||||
|
"encoding": "gbk"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef APP_FREERTOS_TASK_H_
|
||||||
|
#define APP_FREERTOS_TASK_H_
|
||||||
|
|
||||||
|
#include "pDebug.h"
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
void startApp(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,53 @@
|
||||||
|
|
||||||
|
#include "freerotsTask.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "uart_dev.h"
|
||||||
|
#include "HD_UART.h"
|
||||||
|
#include "FM_GPIO.h"
|
||||||
|
#include "FM_ADC.h"
|
||||||
|
|
||||||
|
#define TASK1_TASK_PRIO 5
|
||||||
|
#define TASK1_STK_SIZE 256
|
||||||
|
|
||||||
|
TaskHandle_t Task1Task_Handler;
|
||||||
|
uint8_t data[20] = "hello world\n";
|
||||||
|
|
||||||
|
void task1_task(void *pvParameters)
|
||||||
|
{
|
||||||
|
writePwrCtrlState(Android_PwrCtrl, PwrCtrlOpen);
|
||||||
|
proportionalInt();
|
||||||
|
while(1) {
|
||||||
|
// printf("task1 entry\r\n");
|
||||||
|
printf_adc_data();
|
||||||
|
USART_ITConfig(UART5, USART_IT_TXE, ENABLE);
|
||||||
|
uartInterruptSend(g_Upward_uart5_handle, data, 12);
|
||||||
|
vTaskDelay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Æô¶¯
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void startApp(void)
|
||||||
|
{
|
||||||
|
Init_Upward_uart(115200);
|
||||||
|
FM_GPIO_Init();
|
||||||
|
FM_ADC_Init();
|
||||||
|
|
||||||
|
/* create task */
|
||||||
|
xTaskCreate((TaskFunction_t )task1_task,
|
||||||
|
(const char* )"task1",
|
||||||
|
(uint16_t )TASK1_STK_SIZE,
|
||||||
|
(void* )NULL,
|
||||||
|
(UBaseType_t )TASK1_TASK_PRIO,
|
||||||
|
(TaskHandle_t* )&Task1Task_Handler);
|
||||||
|
vTaskStartScheduler();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef FM_ADC_H_
|
||||||
|
#define FM_ADC_H_
|
||||||
|
|
||||||
|
#include "HD_ADC.h"
|
||||||
|
|
||||||
|
void FM_ADC_Init(void);
|
||||||
|
void printf_adc_data(void);
|
||||||
|
void proportionalInt(void);
|
||||||
|
float getSOCPwrOnVoltage(void);
|
||||||
|
float getInCurrent(void);
|
||||||
|
float getInVoltage(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,32 @@
|
||||||
|
#ifndef FM_GPIO_H_
|
||||||
|
#define FM_GPIO_H_
|
||||||
|
|
||||||
|
#include "HD_GPIO.h"
|
||||||
|
#include "stdio.h"
|
||||||
|
|
||||||
|
typedef enum _pwrCtrl{
|
||||||
|
J1_PwrCtrl = 1,
|
||||||
|
J2_PwrCtrl,
|
||||||
|
J3_PwrCtrl,
|
||||||
|
J4_PwrCtrl,
|
||||||
|
J5_PwrCtrl,
|
||||||
|
J6_PwrCtrl,
|
||||||
|
J7_PwrCtrl,
|
||||||
|
J8_PwrCtrl,
|
||||||
|
J9_PwrCtrl,
|
||||||
|
Android_PwrCtrl,
|
||||||
|
}pwrCtrl;
|
||||||
|
|
||||||
|
typedef enum _pwrCtrlState{
|
||||||
|
PwrCtrlClose = 0,
|
||||||
|
PwrCtrlOpen
|
||||||
|
}pwrCtrlState;
|
||||||
|
|
||||||
|
void FM_GPIO_Init(void);
|
||||||
|
void feedDog(void);
|
||||||
|
void writePwrCtrlState(uint8_t type, uint8_t State);
|
||||||
|
uint8_t readPwrCtrlState(uint8_t type);
|
||||||
|
void startResetAndroidModule(void);
|
||||||
|
void stopResetAndroidModule(void);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
#ifndef FM_FLASH_H_
|
||||||
|
#define FM_FLASH_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
#include "HD_Flash.h"
|
||||||
|
// #include "w25q256.h"
|
||||||
|
|
||||||
|
void Flash_Init(void);
|
||||||
|
void read_Flash(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead);
|
||||||
|
void write_Flash(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite);
|
||||||
|
void erase_Sector_Flash(uint32_t secpos);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,66 @@
|
||||||
|
#ifndef FM_UART_DEV_H_
|
||||||
|
#define FM_UART_DEV_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
#include "HD_UART.h"
|
||||||
|
#include "comm_types.h"
|
||||||
|
#include "ring_queue.h"
|
||||||
|
|
||||||
|
/* 是否使用中断发送,后期可能改为DMA发送 */
|
||||||
|
#define UARTINTERRUPTSEND
|
||||||
|
|
||||||
|
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
|
||||||
|
#define ASCII_CHAR_CHARACTER_TABULATION 0x09 /* '\t' */
|
||||||
|
#define ASCII_CHAR_LINE_FEED 0x0A /* '\n' */
|
||||||
|
#define ASCII_CHAR_LINE_TABULATION 0x0B /* '\v' */
|
||||||
|
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
|
||||||
|
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
J1_485_INDEX = 6,
|
||||||
|
J2_485_INDEX = 7,
|
||||||
|
J3_485_INDEX = 2,
|
||||||
|
J4_485_INDEX = 8,
|
||||||
|
J5_0_485_INDEX = 3,
|
||||||
|
Upward_UART_INDEX = 5,
|
||||||
|
}uartIndex_e;
|
||||||
|
|
||||||
|
typedef struct _uartSendInfo {
|
||||||
|
uint8_t *data; //指向数据
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
uint16_t count; //已经发送数据字节个数
|
||||||
|
uint16_t len; //数据长度
|
||||||
|
#endif
|
||||||
|
}uartSendInfo;
|
||||||
|
|
||||||
|
/* UART 驱动数据结构,对应一个uart设备 */
|
||||||
|
typedef struct _uart_device_info{
|
||||||
|
uint8_t init;
|
||||||
|
uartIndex_e uart_index;
|
||||||
|
uint32_t uart_baudrate;
|
||||||
|
RingQueue uart_ring_queue;
|
||||||
|
uartSendInfo uart_send_data;
|
||||||
|
}uart_device_info;
|
||||||
|
|
||||||
|
typedef uint32_t device_handle;
|
||||||
|
extern device_handle g_J1_uart6_handle;
|
||||||
|
extern device_handle g_J2_uart7_handle;
|
||||||
|
extern device_handle g_J3_usart2_handle;
|
||||||
|
extern device_handle g_J4_uart8_handle;
|
||||||
|
extern device_handle g_J5_0_usart3_handle;
|
||||||
|
extern device_handle g_Upward_uart5_handle;
|
||||||
|
|
||||||
|
uint8_t uart_dev_in_char(device_handle device);
|
||||||
|
int uart_dev_char_present(device_handle device);
|
||||||
|
void Init_J1_485(uint32_t baud);
|
||||||
|
void Init_J2_485(uint32_t baud);
|
||||||
|
void Init_J3_485(uint32_t baud);
|
||||||
|
void Init_J4_485(uint32_t baud);
|
||||||
|
void Init_J5_0_485(uint32_t baud);
|
||||||
|
void Init_Upward_uart(uint32_t baud);
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
uint8_t uartInterruptSend(device_handle device, uint8_t *data, uint16_t len);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,94 @@
|
||||||
|
|
||||||
|
#include "FM_ADC.h"
|
||||||
|
|
||||||
|
/* adc采集转换的比例 */
|
||||||
|
/* 安卓系统启动后输出这个电压 */
|
||||||
|
static float P_PwrOn_Voltage;
|
||||||
|
/* 输入网关的电压 */
|
||||||
|
static float P_In_Voltage;
|
||||||
|
/* 输入网关的电流 */
|
||||||
|
static float P_In_Current;
|
||||||
|
|
||||||
|
/* 参考电压的大小 */
|
||||||
|
#define referenceVoltage 3.3f
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 将采集的adc进行校准
|
||||||
|
* @param val 采集的adc数据
|
||||||
|
* @retval 校准后的adc数据
|
||||||
|
*/
|
||||||
|
static uint16_t Get_ConversionVal(int16_t val)
|
||||||
|
{
|
||||||
|
if((val + Calibrattion_Val) < 0 || val == 0)
|
||||||
|
return 0;
|
||||||
|
if((Calibrattion_Val + val) > 4095 || val == 4095)
|
||||||
|
return 4095;
|
||||||
|
return (val + Calibrattion_Val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化adc
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void FM_ADC_Init(void)
|
||||||
|
{
|
||||||
|
HD_ADC_InIt();
|
||||||
|
ADC_DMA_Init();
|
||||||
|
startAdcCapture();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 打印adc生成的数据
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void printf_adc_data(void)
|
||||||
|
{
|
||||||
|
printf("adc : %d, %d, %d\n", adcData[0], adcData[1], adcData[2]);
|
||||||
|
printf("getSOCPwrOnVoltage: %d\n", (int)(getSOCPwrOnVoltage() * 1000.0f));
|
||||||
|
printf("getInCurrent: %d\n", (int)(getInCurrent() * 1000.0f));
|
||||||
|
printf("getInVoltage: %d\n", (int)(getInVoltage() * 1000.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化转换的比例
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void proportionalInt(void)
|
||||||
|
{
|
||||||
|
P_PwrOn_Voltage = referenceVoltage / 4095.0f;
|
||||||
|
P_In_Voltage = ((100.0f + 10.0f) / 10.0f) * referenceVoltage / 4095.0f;
|
||||||
|
P_In_Current = ((1.0f / 50.0f) / (0.01f)) * referenceVoltage / 4095.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到soc启动后输出电压
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
float getSOCPwrOnVoltage(void)
|
||||||
|
{
|
||||||
|
return (Get_ConversionVal(adcData[0]) * P_PwrOn_Voltage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到输入网关盒子的电流
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
float getInCurrent(void)
|
||||||
|
{
|
||||||
|
return (Get_ConversionVal(adcData[1]) * P_In_Current);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到输入网关盒子的电压
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
float getInVoltage(void)
|
||||||
|
{
|
||||||
|
return (Get_ConversionVal(adcData[2]) * P_In_Voltage);
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
#include "FM_GPIO.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化GPIO
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void FM_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
HD_GPIO_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 喂狗
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void feedDog(void)
|
||||||
|
{
|
||||||
|
HD_GPIO_Write(WDI_GPIO_PROT, WDI_GPIO_PIN, GPIO_RESET);
|
||||||
|
HD_GPIO_Write(WDI_GPIO_PROT, WDI_GPIO_PIN, GPIO_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 电源输出状态设置
|
||||||
|
* @param type 电源输出接口
|
||||||
|
state 输出状态
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void writePwrCtrlState(uint8_t type, uint8_t State)
|
||||||
|
{
|
||||||
|
if (type == J1_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J1_PwrCtrl_GPIO_PROT, J1_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J2_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J2_PwrCtrl_GPIO_PROT, J2_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J3_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J3_PwrCtrl_GPIO_PROT, J3_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J4_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J4_PwrCtrl_GPIO_PROT, J4_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J5_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J5_PwrCtrl_GPIO_PROT, J5_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J6_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J6_PwrCtrl_GPIO_PROT, J6_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J7_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J7_PwrCtrl_GPIO_PROT, J7_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J8_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J8_PwrCtrl_GPIO_PROT, J8_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == J9_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(J9_PwrCtrl_GPIO_PROT, J9_PwrCtrl_GPIO_PIN, State);
|
||||||
|
} else if (type == Android_PwrCtrl) {
|
||||||
|
HD_GPIO_Write(GPIO_PwrCtrl_GPIO_PROT, GPIO_PwrCtrl_GPIO_PIN, State);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 读取电源输出状态
|
||||||
|
* @param type 电源输出接口
|
||||||
|
* @retval state 输出状态
|
||||||
|
0xFF 输入类型错误
|
||||||
|
PwrCtrlClose 关闭状态
|
||||||
|
PwrCtrlOpen 开启状态
|
||||||
|
*/
|
||||||
|
uint8_t readPwrCtrlState(uint8_t type)
|
||||||
|
{
|
||||||
|
if (type == J1_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J1_PwrCtrl_GPIO_PROT, J1_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J2_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J2_PwrCtrl_GPIO_PROT, J2_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J3_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J3_PwrCtrl_GPIO_PROT, J3_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J4_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J4_PwrCtrl_GPIO_PROT, J4_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J5_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J5_PwrCtrl_GPIO_PROT, J5_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J6_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J6_PwrCtrl_GPIO_PROT, J6_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J7_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J7_PwrCtrl_GPIO_PROT, J7_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J8_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J8_PwrCtrl_GPIO_PROT, J8_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == J9_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(J9_PwrCtrl_GPIO_PROT, J9_PwrCtrl_GPIO_PIN);
|
||||||
|
} else if (type == Android_PwrCtrl) {
|
||||||
|
return HD_OutputGPIO_Read(GPIO_PwrCtrl_GPIO_PROT, GPIO_PwrCtrl_GPIO_PIN);
|
||||||
|
}
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 开始复位安卓模块,7-10S后,安卓模块会复位
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void startResetAndroidModule(void)
|
||||||
|
{
|
||||||
|
HD_GPIO_Write(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, GPIO_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 停止复位安卓模块,使用开始复位安卓模块函数7-10S后,安卓模块复位后使用该函数
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void stopResetAndroidModule(void)
|
||||||
|
{
|
||||||
|
HD_GPIO_Write(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, GPIO_RESET);
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include "flash.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief flash初始化
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
void Flash_Init(void)
|
||||||
|
{
|
||||||
|
SPI_Flash_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 读取flash中的数据
|
||||||
|
* @param pBuffer 保存读取的数据
|
||||||
|
* @param ReadAddr 读取数据的位置
|
||||||
|
* @param NumByteToRead 读取数据的长度
|
||||||
|
*/
|
||||||
|
void read_Flash(uint8_t* pBuffer,uint32_t ReadAddr,uint16_t NumByteToRead)
|
||||||
|
{
|
||||||
|
SPI_Flash_Read(pBuffer, ReadAddr, NumByteToRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 将数据写入到flash中
|
||||||
|
* @param pBuffer 要写入的数据
|
||||||
|
* @param ReadAddr 要写入数据的位置
|
||||||
|
* @param NumByteToRead 要写入数据的长度
|
||||||
|
*/
|
||||||
|
void write_Flash(uint8_t* pBuffer,uint32_t WriteAddr,uint16_t NumByteToWrite)
|
||||||
|
{
|
||||||
|
SPI_Flash_Write(pBuffer, WriteAddr, NumByteToWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 清除flash中secpos扇区的数据
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void erase_Sector_Flash(uint32_t secpos)
|
||||||
|
{
|
||||||
|
SPI_Flash_Erase_Sector(secpos);
|
||||||
|
}
|
|
@ -0,0 +1,646 @@
|
||||||
|
#include "uart_dev.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "pDebug.h"
|
||||||
|
|
||||||
|
device_handle g_J1_uart6_handle;
|
||||||
|
device_handle g_J2_uart7_handle;
|
||||||
|
device_handle g_J3_usart2_handle;
|
||||||
|
device_handle g_J4_uart8_handle;
|
||||||
|
device_handle g_J5_0_usart3_handle;
|
||||||
|
device_handle g_Upward_uart5_handle;
|
||||||
|
|
||||||
|
/* 接收缓冲区数组 */
|
||||||
|
uint8_t J1_Rbuffer[1] = {0x00};
|
||||||
|
uint8_t J2_Rbuffer[1] = {0x00};
|
||||||
|
uint8_t J3_Rbuffer[1] = {0x00};
|
||||||
|
uint8_t J4_Rbuffer[1] = {0x00};
|
||||||
|
uint8_t J5_0_Rbuffer[1] = {0x00};
|
||||||
|
uint8_t Upward_Rbuffer[1] = {0x00};
|
||||||
|
|
||||||
|
/* 环形buff */
|
||||||
|
#define J485BuffLen 256
|
||||||
|
uint8_t J1_inBuff[J485BuffLen];
|
||||||
|
uint8_t J2_inBuff[J485BuffLen];
|
||||||
|
uint8_t J3_inBuff[J485BuffLen];
|
||||||
|
uint8_t J4_inBuff[J485BuffLen];
|
||||||
|
uint8_t J5_0_inBuff[J485BuffLen];
|
||||||
|
#define UpwardBuffLen 1024
|
||||||
|
uint8_t Upward_inBuff[UpwardBuffLen];
|
||||||
|
|
||||||
|
/* 用于当做发送时的标志位 8个位,分别对应各个串口 */
|
||||||
|
#define J1_485_Send 0x01
|
||||||
|
#define J2_485_Send 0x02
|
||||||
|
#define J3_485_Send 0x04
|
||||||
|
#define J4_485_Send 0x08
|
||||||
|
#define J5_0_485_Send 0x20
|
||||||
|
#define Upward_uart_Send 0x40
|
||||||
|
static uint8_t uartInterruptSendFlag = 0;
|
||||||
|
|
||||||
|
// static uint8_t getJ1_485_SendState(void);
|
||||||
|
static void setJ1_485_SendState(uint8_t state);
|
||||||
|
// static uint8_t getJ2_485_SendState(void);
|
||||||
|
static void setJ2_485_SendState(uint8_t state);
|
||||||
|
// static uint8_t getJ3_485_SendState(void);
|
||||||
|
static void setJ3_485_SendState(uint8_t state);
|
||||||
|
// static uint8_t getJ4_485_SendState(void);
|
||||||
|
static void setJ4_485_SendState(uint8_t state);
|
||||||
|
// static uint8_t getJ5_0_485_SendState(void);
|
||||||
|
static void setJ5_0_485_SendState(uint8_t state);
|
||||||
|
// static uint8_t getUpward_uart_SendState(void);
|
||||||
|
static void setUpward_uart_SendState(uint8_t state);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 串口信息初始化,串口号及波特率.
|
||||||
|
* @param uart_index 对应的硬件串口号
|
||||||
|
* @param uart_baudrate 波特率
|
||||||
|
*/
|
||||||
|
uart_device_info uart_devices[]={
|
||||||
|
[0] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = J1_485_INDEX,
|
||||||
|
.uart_baudrate = 9600,
|
||||||
|
},
|
||||||
|
[1] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = J2_485_INDEX,
|
||||||
|
.uart_baudrate = 9600,
|
||||||
|
},
|
||||||
|
[2] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = J3_485_INDEX,
|
||||||
|
.uart_baudrate = 9600,
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = J4_485_INDEX,
|
||||||
|
.uart_baudrate = 9600,
|
||||||
|
},
|
||||||
|
[4] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = J5_0_485_INDEX,
|
||||||
|
.uart_baudrate = 9600,
|
||||||
|
},
|
||||||
|
[5] = {
|
||||||
|
.init = 0,
|
||||||
|
.uart_index = Upward_UART_INDEX,
|
||||||
|
.uart_baudrate = 115200,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size);
|
||||||
|
static void uart_init(uartIndex_e uart_index, uint32_t baud);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化串口设备.
|
||||||
|
* @param uart_index 初始化串口号
|
||||||
|
* @param buff 串口循环buff地址
|
||||||
|
* @param buff_size 串口循环buff对应大小
|
||||||
|
* @retval 串口句柄
|
||||||
|
*/
|
||||||
|
device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for (; i < ELEMENT_OF(uart_devices); i++) {
|
||||||
|
if (uart_devices[i].uart_index == uart_index) {
|
||||||
|
if (!uart_devices[i].init) {
|
||||||
|
InitRingQueue(&uart_devices[i].uart_ring_queue, buff, buff_size);
|
||||||
|
uart_init(uart_index, uart_devices[i].uart_baudrate);
|
||||||
|
|
||||||
|
uart_devices[i].init = 1;
|
||||||
|
}
|
||||||
|
return (device_handle)(&uart_devices[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 串口硬件初始化.
|
||||||
|
* @param uart_index 串口号
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void uart_init(uartIndex_e uart_index, uint32_t baud)
|
||||||
|
{
|
||||||
|
if (uart_index == J1_485_INDEX) {
|
||||||
|
J1_485_Init(baud);
|
||||||
|
} else if (uart_index == J2_485_INDEX) {
|
||||||
|
J2_485_Init(baud);
|
||||||
|
} else if (uart_index == J3_485_INDEX) {
|
||||||
|
J3_485_Init(baud);
|
||||||
|
} else if (uart_index == J4_485_INDEX) {
|
||||||
|
J4_485_Init(baud);
|
||||||
|
} else if (uart_index == J5_0_485_INDEX) {
|
||||||
|
J5_0_485_Init(baud);
|
||||||
|
} else if (uart_index == Upward_UART_INDEX) {
|
||||||
|
Upward_UART5_Init(baud);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 从串口设备循环buff读取一个数据.
|
||||||
|
* @param device 串口句柄
|
||||||
|
* @retval 读取到的字符
|
||||||
|
*/
|
||||||
|
uint8_t uart_dev_in_char(device_handle device)
|
||||||
|
{
|
||||||
|
uart_device_info *device_info = (uart_device_info *)device;
|
||||||
|
char c = 0;
|
||||||
|
|
||||||
|
if (uart_dev_char_present(device))
|
||||||
|
OutRingQueue(&device_info->uart_ring_queue, (u_int8_t*)&c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 判断串口设备循环buff是否有数据.
|
||||||
|
* @param device 串口句柄
|
||||||
|
* @retval 0 空 1有数据
|
||||||
|
*/
|
||||||
|
int uart_dev_char_present(device_handle device)
|
||||||
|
{
|
||||||
|
uart_device_info *device_info = (uart_device_info *)device;
|
||||||
|
|
||||||
|
if((!device) || (!device_info->init))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return !RingQueueEmpty(&device_info->uart_ring_queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 初始化 */
|
||||||
|
void Init_J1_485(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[0].uart_baudrate = baud;
|
||||||
|
g_J1_uart6_handle = uart_dev_init(J1_485_INDEX, J1_inBuff, J485BuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_J2_485(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[1].uart_baudrate = baud;
|
||||||
|
g_J2_uart7_handle = uart_dev_init(J2_485_INDEX, J2_inBuff, J485BuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_J3_485(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[2].uart_baudrate = baud;
|
||||||
|
g_J3_usart2_handle = uart_dev_init(J3_485_INDEX, J3_inBuff, J485BuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_J4_485(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[3].uart_baudrate = baud;
|
||||||
|
g_J4_uart8_handle = uart_dev_init(J4_485_INDEX, J4_inBuff, J485BuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_J5_0_485(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[4].uart_baudrate = baud;
|
||||||
|
g_J5_0_usart3_handle = uart_dev_init(J5_0_485_INDEX, J5_0_inBuff, J485BuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Init_Upward_uart(uint32_t baud)
|
||||||
|
{
|
||||||
|
uart_devices[5].uart_baudrate = baud;
|
||||||
|
g_Upward_uart5_handle = uart_dev_init(Upward_UART_INDEX, Upward_inBuff, UpwardBuffLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到串口的发送状态
|
||||||
|
* @param device 设备
|
||||||
|
* @retval 0:发生完成 1:发送中 0xFF:错误
|
||||||
|
*/
|
||||||
|
uint8_t getUartSendState(device_handle device)
|
||||||
|
{
|
||||||
|
if (device == g_J1_uart6_handle) {
|
||||||
|
return uartInterruptSendFlag & J1_485_Send;
|
||||||
|
}
|
||||||
|
else if (device == g_J2_uart7_handle) {
|
||||||
|
return uartInterruptSendFlag & J2_485_Send;
|
||||||
|
}
|
||||||
|
else if (device == g_J3_usart2_handle) {
|
||||||
|
return uartInterruptSendFlag & J3_485_Send;
|
||||||
|
}
|
||||||
|
else if (device == g_J4_uart8_handle) {
|
||||||
|
return uartInterruptSendFlag & J4_485_Send;
|
||||||
|
}
|
||||||
|
else if (device == g_J5_0_usart3_handle) {
|
||||||
|
return uartInterruptSendFlag & J5_0_485_Send;
|
||||||
|
}
|
||||||
|
else if (device == g_Upward_uart5_handle) {
|
||||||
|
return uartInterruptSendFlag & Upward_uart_Send;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @brief 设置设备的发送状态
|
||||||
|
// * @param
|
||||||
|
// state 0:发生完成 1:发送中
|
||||||
|
// * @retval
|
||||||
|
// */
|
||||||
|
// void setUartSendState(device_handle device, uint8_t state)
|
||||||
|
// {
|
||||||
|
// if (device == g_J1_uart6_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= J1_485_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~J1_485_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (device == g_J2_uart7_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= J2_485_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~J2_485_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (device == g_J3_usart2_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= J3_485_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~J3_485_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (device == g_J4_uart8_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= J4_485_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~J4_485_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (device == g_J5_0_usart3_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= J5_0_485_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~J5_0_485_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (device == g_Upward_uart5_handle) {
|
||||||
|
// if (state == 1) {
|
||||||
|
// uartInterruptSendFlag |= Upward_uart_Send;
|
||||||
|
// }
|
||||||
|
// else if (state == 0) {
|
||||||
|
// uartInterruptSendFlag &= (~Upward_uart_Send);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到J2_485的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getJ1_485_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & J1_485_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置J2_485的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setJ1_485_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= J1_485_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~J1_485_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到J2_485的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getJ2_485_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & J2_485_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置J2_485的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setJ2_485_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= J2_485_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~J2_485_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到J3_485的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getJ3_485_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & J3_485_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置J3_485的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setJ3_485_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= J3_485_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~J3_485_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到J4_485的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getJ4_485_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & J4_485_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置J4_485的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setJ4_485_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= J4_485_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~J4_485_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到J5_0_485的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getJ5_0_485_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & J5_0_485_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置J1_485的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setJ5_0_485_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= J5_0_485_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~J5_0_485_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到Upward_uart的发送状态
|
||||||
|
* @param
|
||||||
|
* @retval 0:发生完成 1:发送中
|
||||||
|
*/
|
||||||
|
uint8_t getUpward_uart_SendState(void)
|
||||||
|
{
|
||||||
|
return uartInterruptSendFlag & Upward_uart_Send;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置Upward_uart的发送状态
|
||||||
|
* @param 0:发生完成 1:发送中
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void setUpward_uart_SendState(uint8_t state)
|
||||||
|
{
|
||||||
|
if (state == 1) {
|
||||||
|
uartInterruptSendFlag |= Upward_uart_Send;
|
||||||
|
}
|
||||||
|
else if (state == 0) {
|
||||||
|
uartInterruptSendFlag &= (~Upward_uart_Send);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 串口中断处理函数 */
|
||||||
|
void J3_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(J3_USART, USART_IT_RXNE) != RESET) {
|
||||||
|
J3_Rbuffer[0] = USART_ReceiveData(J3_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J3_usart2_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, J3_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(J3_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J3_usart2_handle;
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(J3_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setJ3_485_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(J3_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void J5_0_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(J5_0_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||||
|
J5_0_Rbuffer[0] = USART_ReceiveData(J5_0_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J5_0_usart3_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, J5_0_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(J5_0_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J5_0_usart3_handle;
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(J5_0_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setJ5_0_485_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(J5_0_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void Upward_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(Upward_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||||
|
Upward_Rbuffer[0] = USART_ReceiveData(Upward_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_Upward_uart5_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, Upward_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(Upward_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_Upward_uart5_handle;
|
||||||
|
// log_info("%d \n", dev->uart_send_data.count);
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(Upward_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setUpward_uart_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(Upward_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void J1_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(J1_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||||
|
J1_Rbuffer[0] = USART_ReceiveData(J1_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J1_uart6_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, J1_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(J1_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J1_uart6_handle;
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(J1_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setJ1_485_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(J1_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void J2_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(J2_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||||
|
J2_Rbuffer[0] = USART_ReceiveData(J2_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J2_uart7_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, J2_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(J2_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J2_uart7_handle;
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(J2_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setJ2_485_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(J2_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void J4_Interrupt()
|
||||||
|
{
|
||||||
|
/* 数据接收中断 */
|
||||||
|
if (USART_GetITStatus(J4_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||||
|
J4_Rbuffer[0] = USART_ReceiveData(J4_USART); //接收数据
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J4_uart8_handle;
|
||||||
|
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||||
|
InRingQueue(&dev->uart_ring_queue, J4_Rbuffer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/* 数据发送中断 */
|
||||||
|
if (USART_GetITStatus(J4_USART, USART_IT_TXE) != RESET) {
|
||||||
|
uart_device_info *dev = (uart_device_info *)g_J4_uart8_handle;
|
||||||
|
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||||
|
USART_ITConfig(J4_USART, USART_IT_TXE, DISABLE);
|
||||||
|
setJ4_485_SendState(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
USART_SendData(J4_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef UARTINTERRUPTSEND
|
||||||
|
/**
|
||||||
|
* @brief 通过中断发送
|
||||||
|
* @param device 设备
|
||||||
|
data 指向数据的指针
|
||||||
|
len 数据长度
|
||||||
|
* @retval 0:成功
|
||||||
|
1:上次数据还未发送完成
|
||||||
|
0xFF:错误
|
||||||
|
*/
|
||||||
|
uint8_t uartInterruptSend(device_handle device,uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
/* 上次未发送完,或设备不存在 */
|
||||||
|
if (getUartSendState(device)) {
|
||||||
|
return getUartSendState(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 指向数据 */
|
||||||
|
uart_device_info *dev = (uart_device_info *)device;
|
||||||
|
dev->uart_send_data.data = data;
|
||||||
|
dev->uart_send_data.count = 0;
|
||||||
|
dev->uart_send_data.len = len;
|
||||||
|
|
||||||
|
/* 开始发送 */
|
||||||
|
if (device == g_J1_uart6_handle) {
|
||||||
|
USART_ITConfig(J1_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(J1_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
else if (device == g_J2_uart7_handle) {
|
||||||
|
USART_ITConfig(J2_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(J2_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
else if (device == g_J3_usart2_handle) {
|
||||||
|
USART_ITConfig(J3_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(J3_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
else if (device == g_J4_uart8_handle) {
|
||||||
|
USART_ITConfig(J4_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(J4_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
else if (device == g_J5_0_usart3_handle) {
|
||||||
|
USART_ITConfig(J5_0_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(J5_0_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
else if (device == g_Upward_uart5_handle) {
|
||||||
|
USART_ITConfig(Upward_USART, USART_IT_TXE, ENABLE);
|
||||||
|
USART_SendData(Upward_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef HD_ADC_H_
|
||||||
|
#define HD_ADC_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
|
||||||
|
extern uint16_t adcData[];
|
||||||
|
extern int16_t Calibrattion_Val;
|
||||||
|
|
||||||
|
/* adc采集的数据的数组对应的内容 */
|
||||||
|
#define PwrOnNum 0
|
||||||
|
#define CurrentNum 1
|
||||||
|
#define VoltageNum 2
|
||||||
|
|
||||||
|
void HD_ADC_InIt(void);
|
||||||
|
void ADC_DMA_Init(void);
|
||||||
|
void startAdcCapture(void);
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* Flash.h
|
||||||
|
*
|
||||||
|
* Created on: 2024年5月16日
|
||||||
|
* Author: 34509
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HARDWARE_SPI_FLASH_H_
|
||||||
|
#define HARDWARE_SPI_FLASH_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************
|
||||||
|
|
||||||
|
*@Note
|
||||||
|
|
||||||
|
Winbond W25Qxx SPIFLASH
|
||||||
|
|
||||||
|
pins:
|
||||||
|
|
||||||
|
CS —— PA15(SPI3_NSS)
|
||||||
|
|
||||||
|
DO —— PB4(SPI3_MISO)
|
||||||
|
|
||||||
|
WP —— 3.3V
|
||||||
|
|
||||||
|
DI —— PB5(SPI3_MOSI)
|
||||||
|
|
||||||
|
CLK —— PB3(SPI3_SCK)
|
||||||
|
|
||||||
|
HOLD —— 3.3V
|
||||||
|
|
||||||
|
*******************************************/
|
||||||
|
#define RCC_APB2Periph_GPIOX RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB
|
||||||
|
#define RCC_APB1Periph_SPIX RCC_APB1Periph_SPI3
|
||||||
|
|
||||||
|
#define CS_PIN GPIO_Pin_15
|
||||||
|
#define CS_GPIO GPIOA
|
||||||
|
|
||||||
|
#define DO_PIN GPIO_Pin_4
|
||||||
|
#define DO_GPIO GPIOB
|
||||||
|
|
||||||
|
#define DI_PIN GPIO_Pin_5
|
||||||
|
#define DI_GPIO GPIOB
|
||||||
|
|
||||||
|
#define CLK_PIN GPIO_Pin_3
|
||||||
|
#define CLK_GPIO GPIOB
|
||||||
|
|
||||||
|
#define SPIX SPI3
|
||||||
|
|
||||||
|
/* Winbond SPI Falsh ID */
|
||||||
|
#define W25Q80 0XEF13
|
||||||
|
#define W25Q16 0XEF14
|
||||||
|
#define W25Q32 0XEF15
|
||||||
|
#define W25Q64 0XEF16
|
||||||
|
#define W25Q128 0XEF17
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Winbond SPIFalsh Instruction List 指令表 */
|
||||||
|
#define W25X_WriteEnable 0x06
|
||||||
|
#define W25X_WriteDisable 0x04
|
||||||
|
#define W25X_ReadStatusReg 0x05
|
||||||
|
#define W25X_WriteStatusReg 0x01
|
||||||
|
#define W25X_ReadData 0x03
|
||||||
|
#define W25X_FastReadData 0x0B
|
||||||
|
#define W25X_FastReadDual 0x3B
|
||||||
|
#define W25X_PageProgram 0x02
|
||||||
|
#define W25X_BlockErase 0xD8
|
||||||
|
#define W25X_SectorErase 0x20
|
||||||
|
#define W25X_ChipErase 0xC7
|
||||||
|
#define W25X_PowerDown 0xB9
|
||||||
|
#define W25X_ReleasePowerDown 0xAB
|
||||||
|
#define W25X_DeviceID 0xAB
|
||||||
|
#define W25X_ManufactDeviceID 0x90
|
||||||
|
#define W25X_JedecDeviceID 0x9F
|
||||||
|
|
||||||
|
void SPI_Flash_Init(void);
|
||||||
|
u8 SPI_ReadWriteByte(u8 TxData);
|
||||||
|
u8 SPI_Flash_ReadSR(void);
|
||||||
|
void SPI_FLASH_Write_SR(u8 sr);
|
||||||
|
void SPI_Flash_Wait_Busy(void);
|
||||||
|
void SPI_FLASH_Write_Enable(void);
|
||||||
|
void SPI_FLASH_Write_Disable(void);
|
||||||
|
u16 SPI_Flash_ReadID(void);
|
||||||
|
void SPI_Flash_Erase_Sector(u32 Dst_Addr);
|
||||||
|
void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 size);
|
||||||
|
void SPI_Flash_Write_Page(u8* pBuffer,u32 WriteAddr,u16 size);
|
||||||
|
void SPI_Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 size);
|
||||||
|
void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 size);
|
||||||
|
void SPI_Flash_Erase_Chip(void);
|
||||||
|
void SPI_Flash_PowerDown(void);
|
||||||
|
void SPI_Flash_WAKEUP(void);
|
||||||
|
|
||||||
|
void SPI_Flash_TEST(void);
|
||||||
|
|
||||||
|
#endif /* HARDWARE_SPI_FLASH_H_ */
|
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef HD_GPIO_H_
|
||||||
|
#define HD_GPIO_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
|
||||||
|
/* 든都왠齡多신 */
|
||||||
|
#define J1_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J1_PwrCtrl_GPIO_PIN GPIO_Pin_7
|
||||||
|
#define J2_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J2_PwrCtrl_GPIO_PIN GPIO_Pin_8
|
||||||
|
#define J3_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J3_PwrCtrl_GPIO_PIN GPIO_Pin_9
|
||||||
|
#define J4_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J4_PwrCtrl_GPIO_PIN GPIO_Pin_10
|
||||||
|
#define J5_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J5_PwrCtrl_GPIO_PIN GPIO_Pin_11
|
||||||
|
#define J6_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J6_PwrCtrl_GPIO_PIN GPIO_Pin_12
|
||||||
|
#define J7_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J7_PwrCtrl_GPIO_PIN GPIO_Pin_13
|
||||||
|
#define J8_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J8_PwrCtrl_GPIO_PIN GPIO_Pin_14
|
||||||
|
#define J9_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define J9_PwrCtrl_GPIO_PIN GPIO_Pin_15
|
||||||
|
|
||||||
|
/* 갛六친욥묩든賈콘多신 */
|
||||||
|
#define GPIO_PwrCtrl_GPIO_PROT GPIOE
|
||||||
|
#define GPIO_PwrCtrl_GPIO_PIN GPIO_Pin_3
|
||||||
|
|
||||||
|
/* 갛六친욥윗됴릿貫多신 */
|
||||||
|
#define GPIO_PwrKey_GPIO_PROT GPIOE
|
||||||
|
#define GPIO_PwrKey_GPIO_PIN GPIO_Pin_2
|
||||||
|
|
||||||
|
/* 菅뭍多신 */
|
||||||
|
#define WDI_GPIO_PROT GPIOC
|
||||||
|
#define WDI_GPIO_PIN GPIO_Pin_13
|
||||||
|
|
||||||
|
#define GPIOTypeDef GPIO_TypeDef
|
||||||
|
#define GPIOPin uint16_t
|
||||||
|
|
||||||
|
/* Bit_SET and Bit_RESET enumeration */
|
||||||
|
typedef enum {
|
||||||
|
GPIO_RESET = 0,
|
||||||
|
GPIO_SET
|
||||||
|
}BitOperation;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void HD_GPIO_Init(void);
|
||||||
|
void HD_GPIO_Write(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin, BitOperation BitVal);
|
||||||
|
uint8_t HD_InputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
||||||
|
uint8_t HD_OutputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,103 @@
|
||||||
|
#ifndef HARDWARE_RS485_UART_H_
|
||||||
|
#define HARDWARE_RS485_UART_H_
|
||||||
|
|
||||||
|
#include "ch32v30x.h"
|
||||||
|
|
||||||
|
// #define uart4_enable
|
||||||
|
|
||||||
|
|
||||||
|
#define J1_USART UART6
|
||||||
|
#define J2_USART UART7
|
||||||
|
#define J3_USART USART2
|
||||||
|
#define J4_USART UART8
|
||||||
|
#define J5_0_USART USART3
|
||||||
|
#define Upward_USART UART5
|
||||||
|
|
||||||
|
/* 串口6 PE5 */
|
||||||
|
#define J1_DE_PROT GPIOE
|
||||||
|
#define J1_DE_PIN GPIO_Pin_5
|
||||||
|
|
||||||
|
/* 串口7 PE6 */
|
||||||
|
#define J2_DE_PROT GPIOE
|
||||||
|
#define J2_DE_PIN GPIO_Pin_6
|
||||||
|
|
||||||
|
/* 串口2 PA1 */
|
||||||
|
#define J3_DE_PROT GPIOA
|
||||||
|
#define J3_DE_PIN GPIO_Pin_1
|
||||||
|
|
||||||
|
/* 串口8 PE5 */
|
||||||
|
#define J4_DE_PROT GPIOB
|
||||||
|
#define J4_DE_PIN GPIO_Pin_0
|
||||||
|
|
||||||
|
/* 串口3 分时复用 */
|
||||||
|
/*
|
||||||
|
| A - B - C - YX |
|
||||||
|
| 0 - 0 - 0 - J0 |
|
||||||
|
| 0 - 0 - 1 - J5 |
|
||||||
|
| 0 - 1 - 0 - J6 |
|
||||||
|
| 0 - 1 - 1 - J7 |
|
||||||
|
| 1 - 0 - 0 - J8 |
|
||||||
|
| 1 - 0 - 1 - J9 |
|
||||||
|
*/
|
||||||
|
#define J5_0_DE_PROT GPIOD
|
||||||
|
#define J5_0_DE_PIN GPIO_Pin_8
|
||||||
|
#define J5_0_A_PROT GPIOD
|
||||||
|
#define J5_0_A_PIN GPIO_Pin_9
|
||||||
|
#define J5_0_B_PROT GPIOD
|
||||||
|
#define J5_0_B_PIN GPIO_Pin_10
|
||||||
|
#define J5_0_C_PROT GPIOD
|
||||||
|
#define J5_0_C_PIN GPIO_Pin_11
|
||||||
|
|
||||||
|
#define write485 Bit_SET
|
||||||
|
#define read485 Bit_RESET
|
||||||
|
|
||||||
|
/* J1_UART6 */
|
||||||
|
void J1_485_Init(uint32_t baud);
|
||||||
|
#define readJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, read485);
|
||||||
|
#define writeJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, write485);
|
||||||
|
|
||||||
|
/* J2_UART7 */
|
||||||
|
void J2_485_Init(uint32_t baud);
|
||||||
|
#define readJ2_485 GPIO_WriteBit(J2_DE_PROT, J2_DE_PIN, read485);
|
||||||
|
#define writeJ2_485 GPIO_WriteBit(J2_DE_PROT, J2_DE_PIN, write485);
|
||||||
|
|
||||||
|
/* J3_USART2 */
|
||||||
|
void J3_485_Init(uint32_t baud);
|
||||||
|
#define readJ3_485 GPIO_WriteBit(J3_DE_PROT, J3_DE_PIN, read485);
|
||||||
|
#define writeJ3_485 GPIO_WriteBit(J3_DE_PROT, J3_DE_PIN, write485);
|
||||||
|
|
||||||
|
/* J4_UART8 */
|
||||||
|
void J4_485_Init(uint32_t baud);
|
||||||
|
#define readJ4_485 GPIO_WriteBit(J4_DE_PROT, J4_DE_PIN, read485);
|
||||||
|
#define writeJ4_485 GPIO_WriteBit(J4_DE_PROT, J4_DE_PIN, write485);
|
||||||
|
|
||||||
|
/* J0-5_USART3 */
|
||||||
|
void J5_0_485_Init(uint32_t baud);
|
||||||
|
#define readJ5_0_485 GPIO_WriteBit(J5_0_DE_PROT, J5_0_DE_PIN, read485);
|
||||||
|
#define writeJ5_0_485 GPIO_WriteBit(J5_0_DE_PROT, J5_0_DE_PIN, write485);
|
||||||
|
void USART_CONNET_J0(void);
|
||||||
|
void USART_CONNET_J5(void);
|
||||||
|
void USART_CONNET_J6(void);
|
||||||
|
void USART_CONNET_J7(void);
|
||||||
|
void USART_CONNET_J8(void);
|
||||||
|
void USART_CONNET_J9(void);
|
||||||
|
|
||||||
|
#ifdef uart4_enable
|
||||||
|
/* LORA_UART4 */
|
||||||
|
void LORA_UART4_Init(uint32_t baud);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Upward_UART5 */
|
||||||
|
void Upward_UART5_Init(uint32_t baud);
|
||||||
|
|
||||||
|
extern void J3_Interrupt();
|
||||||
|
extern void J5_0_Interrupt();
|
||||||
|
extern void Upward_Interrupt();
|
||||||
|
extern void J1_Interrupt();
|
||||||
|
extern void J2_Interrupt();
|
||||||
|
extern void J4_Interrupt();
|
||||||
|
|
||||||
|
void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data);
|
||||||
|
void USARTx_SendStr_Len(USART_TypeDef* pUSARTx, char *str, int len);
|
||||||
|
|
||||||
|
#endif /* HARDWARE_RS485_UART_H_ */
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
#include "HD_ADC.h"
|
||||||
|
|
||||||
|
/* adc校准值 */
|
||||||
|
int16_t Calibrattion_Val = 0;
|
||||||
|
#define adcNum 3
|
||||||
|
/* 通过dma将adc采集的数据存入 */
|
||||||
|
uint16_t adcData[adcNum] = {0};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化adc
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void HD_ADC_InIt(void)
|
||||||
|
{
|
||||||
|
ADC_InitTypeDef ADC_InitStructure={0};
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure={0};
|
||||||
|
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE );
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE );
|
||||||
|
RCC_ADCCLKConfig(RCC_PCLK2_Div4);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
ADC_DeInit(ADC1);
|
||||||
|
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
|
||||||
|
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
|
||||||
|
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
|
||||||
|
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
|
||||||
|
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
|
||||||
|
ADC_InitStructure.ADC_NbrOfChannel = adcNum;
|
||||||
|
ADC_Init(ADC1, &ADC_InitStructure);
|
||||||
|
|
||||||
|
ADC_DMACmd(ADC1, ENABLE);
|
||||||
|
ADC_Cmd(ADC1, ENABLE);
|
||||||
|
|
||||||
|
ADC_BufferCmd(ADC1, DISABLE); //disable buffer
|
||||||
|
ADC_ResetCalibration(ADC1);
|
||||||
|
while(ADC_GetResetCalibrationStatus(ADC1));
|
||||||
|
ADC_StartCalibration(ADC1);
|
||||||
|
while(ADC_GetCalibrationStatus(ADC1));
|
||||||
|
Calibrattion_Val = Get_CalibrationValue(ADC1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 初始化adc的dma输出
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void ADC_DMA_Init(void)
|
||||||
|
{
|
||||||
|
DMA_InitTypeDef DMA_InitStructure={0};
|
||||||
|
|
||||||
|
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
|
||||||
|
|
||||||
|
DMA_DeInit(DMA1_Channel1);
|
||||||
|
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->RDATAR;
|
||||||
|
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adcData;
|
||||||
|
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||||
|
DMA_InitStructure.DMA_BufferSize = adcNum;
|
||||||
|
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||||
|
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||||
|
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
|
||||||
|
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
|
||||||
|
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
|
||||||
|
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
|
||||||
|
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||||
|
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 启动adc采集
|
||||||
|
* @param
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void startAdcCapture(void)
|
||||||
|
{
|
||||||
|
/* 使能adc采样通道 */
|
||||||
|
DMA_Cmd(DMA1_Channel1 , ENABLE);
|
||||||
|
|
||||||
|
/* 设置转换顺序 */
|
||||||
|
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5);
|
||||||
|
ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 2, ADC_SampleTime_239Cycles5);
|
||||||
|
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 3, ADC_SampleTime_239Cycles5);
|
||||||
|
|
||||||
|
/* 使能ADC的dma请求 */
|
||||||
|
ADC_DMACmd(ADC1, ENABLE);
|
||||||
|
|
||||||
|
/* 触发adc采样 */
|
||||||
|
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
|
||||||
|
}
|
|
@ -0,0 +1,456 @@
|
||||||
|
/*
|
||||||
|
* Flash.c
|
||||||
|
*
|
||||||
|
* Created on: 2024年5月16日
|
||||||
|
* Author: 34509
|
||||||
|
*/
|
||||||
|
#include "HD_Flash.h"
|
||||||
|
#include "pDebug.h"
|
||||||
|
|
||||||
|
/* Global Variable */
|
||||||
|
uint8_t SPI_FLASH_BUF[4096];
|
||||||
|
|
||||||
|
void delay_us(uint32_t us) {
|
||||||
|
volatile uint32_t cycles = us * SystemCoreClock / 4000000; // 根据实测调整
|
||||||
|
while (cycles--) {
|
||||||
|
__asm__ volatile ("nop"); // 防止循环被优化
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Init
|
||||||
|
* Description : Configuring the SPI for operation flash.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Init(void)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
SPI_InitTypeDef SPI_InitStructure;
|
||||||
|
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOX, ENABLE );
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPIX, ENABLE );
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = CS_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(CS_GPIO, &GPIO_InitStructure);
|
||||||
|
GPIO_SetBits(CS_GPIO, CS_PIN); //CS引脚PA15置高电平
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = CLK_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(CLK_GPIO, &GPIO_InitStructure );
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = DO_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //浮空输入
|
||||||
|
GPIO_Init(DO_GPIO, &GPIO_InitStructure );
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = DI_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(DI_GPIO, &GPIO_InitStructure );
|
||||||
|
|
||||||
|
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex; //设置SPI通讯方向为双线全双工方式
|
||||||
|
SPI_InitStructure.SPI_Mode = SPI_Mode_Master; //设置SPI为主机端模式
|
||||||
|
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b; //设置SPI通讯的数据帧大小为8位
|
||||||
|
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High; //设置SPI的时钟极性为高电平
|
||||||
|
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; //设置SPI的时钟相位为在SCK的偶数边沿采集数据
|
||||||
|
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft; //设置NSS引脚(即片选引脚)的使用模式为软件模式
|
||||||
|
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4; //设置波特率分频因子为4分频
|
||||||
|
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB; //设置数据传输为高位数据在前
|
||||||
|
SPI_InitStructure.SPI_CRCPolynomial = 7; //SPI的CRC校验中多项式的值
|
||||||
|
SPI_Init(SPIX, &SPI_InitStructure); //初始化SPI
|
||||||
|
|
||||||
|
SPI_Cmd(SPIX, ENABLE); //使能SPI3外设
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPIX_ReadWriteByte
|
||||||
|
* Description : SPIX read or write one byte.
|
||||||
|
* Input : TxData: write one byte data.
|
||||||
|
* Return : Read one byte data.
|
||||||
|
*******************************************************************************/
|
||||||
|
u8 SPI_ReadWriteByte(u8 TxData)
|
||||||
|
{
|
||||||
|
u8 i=0;
|
||||||
|
while (SPI_I2S_GetFlagStatus(SPIX, SPI_I2S_FLAG_TXE) == RESET) //等待发送缓冲区为空,TXE事件
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if(i>200)return 0;
|
||||||
|
}
|
||||||
|
SPI_I2S_SendData(SPIX, TxData); //写入数据寄存器,把要写入的数据写入发送缓冲区,即通过外设SPI1发送一个数据
|
||||||
|
i=0;
|
||||||
|
while (SPI_I2S_GetFlagStatus(SPIX, SPI_I2S_FLAG_RXNE) == RESET) //等待接收缓冲区非空,RXNE事件
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
if(i>200)return 0;
|
||||||
|
}
|
||||||
|
return SPI_I2S_ReceiveData(SPIX); //读取数据寄存器,获取接收缓冲区数据,即返回SPI1最近接收到的数据
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_ReadSR
|
||||||
|
* Description : Read W25Qxx status register.
|
||||||
|
* ——BIT7 6 5 4 3 2 1 0
|
||||||
|
* ——SPR RV TB BP2 BP1 BP0 WEL BUSY
|
||||||
|
* Input : None
|
||||||
|
* Return : byte: status register value.
|
||||||
|
*******************************************************************************/
|
||||||
|
u8 SPI_Flash_ReadSR(void)
|
||||||
|
{
|
||||||
|
u8 byte=0;
|
||||||
|
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0); //PA2=0,使能片选信号
|
||||||
|
SPI_ReadWriteByte(W25X_ReadStatusReg); //发送读状态寄存器命令
|
||||||
|
byte=SPI_ReadWriteByte(0Xff); //读取一个字节
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1); //取消片选信号
|
||||||
|
|
||||||
|
return byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_FLASH_Write_SR
|
||||||
|
* Description : Write W25Qxx status register.
|
||||||
|
* Input : sr:status register value.
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_FLASH_Write_SR(u8 sr)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_WriteStatusReg); //发送写状态寄存器命令
|
||||||
|
SPI_ReadWriteByte(sr); //写入一个字节
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Wait_Busy
|
||||||
|
* Description : Wait flash free.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Wait_Busy(void)
|
||||||
|
{
|
||||||
|
while((SPI_Flash_ReadSR()&0x01)==0x01); //等待FLASH空闲
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_FLASH_Write_Enable
|
||||||
|
* Description : Enable flash write.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_FLASH_Write_Enable(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_WriteEnable); //发送写使能
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_FLASH_Write_Disable
|
||||||
|
* Description : Disable flash write.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_FLASH_Write_Disable(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_WriteDisable); //发送写禁止指令
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_ReadID
|
||||||
|
* Description : Read flash ID.
|
||||||
|
* Input : None
|
||||||
|
* Return : Temp: FLASH ID.
|
||||||
|
*******************************************************************************/
|
||||||
|
u16 SPI_Flash_ReadID(void)
|
||||||
|
{
|
||||||
|
u16 Temp = 0;
|
||||||
|
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_ManufactDeviceID); //发送读取ID命令
|
||||||
|
SPI_ReadWriteByte(0x00);
|
||||||
|
SPI_ReadWriteByte(0x00);
|
||||||
|
SPI_ReadWriteByte(0x00);
|
||||||
|
Temp|=SPI_ReadWriteByte(0xFF)<<8;
|
||||||
|
Temp|=SPI_ReadWriteByte(0xFF);
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
|
||||||
|
return Temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Erase_Sector
|
||||||
|
* Description : Erase one sector(4Kbyte).
|
||||||
|
* Input : Dst_Addr: 0 —— 2047
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Erase_Sector(u32 Dst_Addr)
|
||||||
|
{
|
||||||
|
Dst_Addr*=4096;
|
||||||
|
SPI_FLASH_Write_Enable();
|
||||||
|
SPI_Flash_Wait_Busy();
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_SectorErase); //发送扇区擦除指令
|
||||||
|
SPI_ReadWriteByte((u8)((Dst_Addr)>>16)); //发送24bit地址
|
||||||
|
SPI_ReadWriteByte((u8)((Dst_Addr)>>8));
|
||||||
|
SPI_ReadWriteByte((u8)Dst_Addr);
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
SPI_Flash_Wait_Busy(); //等待擦除完成
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Read
|
||||||
|
* Description : Read data from flash.
|
||||||
|
* Input : pBuffer:
|
||||||
|
* ReadAddr:Initial address(24bit).
|
||||||
|
* size: Data length.
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Read(u8* pBuffer,u32 ReadAddr,u16 size)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_ReadData); //发送读取命令
|
||||||
|
SPI_ReadWriteByte((u8)((ReadAddr)>>16)); //发送24bit地址
|
||||||
|
SPI_ReadWriteByte((u8)((ReadAddr)>>8));
|
||||||
|
SPI_ReadWriteByte((u8)ReadAddr);
|
||||||
|
|
||||||
|
for(i=0;i<size;i++)
|
||||||
|
{
|
||||||
|
pBuffer[i] = SPI_ReadWriteByte(0XFF); //循环读数
|
||||||
|
}
|
||||||
|
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Write_Page
|
||||||
|
* Description : Write data by one page.
|
||||||
|
* Input : pBuffer:
|
||||||
|
* WriteAddr:Initial address(24bit).
|
||||||
|
* size:Data length.
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Write_Page(u8* pBuffer,u32 WriteAddr,u16 size)
|
||||||
|
{
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
SPI_FLASH_Write_Enable();
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_PageProgram); //发送写页命令
|
||||||
|
SPI_ReadWriteByte((u8)((WriteAddr)>>16)); //发送24bit地址
|
||||||
|
SPI_ReadWriteByte((u8)((WriteAddr)>>8));
|
||||||
|
SPI_ReadWriteByte((u8)WriteAddr);
|
||||||
|
|
||||||
|
for(i=0;i<size;i++)
|
||||||
|
{
|
||||||
|
SPI_ReadWriteByte(pBuffer[i]); //循环写数
|
||||||
|
}
|
||||||
|
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
SPI_Flash_Wait_Busy(); //等待写入结束
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Write_NoCheck
|
||||||
|
* Description : Write data to flash.(need Erase)
|
||||||
|
* All data in address rang is 0xFF.
|
||||||
|
* Input : pBuffer:
|
||||||
|
* WriteAddr: Initial address(24bit).
|
||||||
|
* size: Data length.
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Write_NoCheck(u8* pBuffer,u32 WriteAddr,u16 size)
|
||||||
|
{
|
||||||
|
u16 pageremain;
|
||||||
|
|
||||||
|
pageremain=256-WriteAddr%256; //单页剩余的字节数
|
||||||
|
|
||||||
|
if(size<=pageremain)pageremain=size; //不大于256个字节
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
SPI_Flash_Write_Page(pBuffer,WriteAddr,pageremain);
|
||||||
|
|
||||||
|
if(size==pageremain)
|
||||||
|
{
|
||||||
|
break; //写入结束了
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pBuffer+=pageremain;
|
||||||
|
WriteAddr+=pageremain;
|
||||||
|
size-=pageremain; //减去已经写入了的字节数
|
||||||
|
|
||||||
|
if(size>256)pageremain=256; //一次可以写入256个字节
|
||||||
|
else pageremain=size; //不够256个字节了
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Write
|
||||||
|
* Description : Write data to flash.(no need Erase)
|
||||||
|
* Input : pBuffer:
|
||||||
|
* WriteAddr: Initial address(24bit).
|
||||||
|
* size: Data length.
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Write(u8* pBuffer,u32 WriteAddr,u16 size)
|
||||||
|
{
|
||||||
|
u32 secpos;
|
||||||
|
u16 secoff;
|
||||||
|
u16 secremain;
|
||||||
|
u16 i;
|
||||||
|
|
||||||
|
secpos=WriteAddr/4096; //扇区地址
|
||||||
|
secoff=WriteAddr%4096; //在扇区内的便宜
|
||||||
|
secremain=4096-secoff; //扇区剩余空间大小
|
||||||
|
|
||||||
|
if(size<=secremain)secremain=size; //不大于4096个字节
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
SPI_Flash_Read(SPI_FLASH_BUF,secpos*4096,4096); //读出整个扇区的内容
|
||||||
|
|
||||||
|
for(i=0;i<secremain;i++) //校验数据
|
||||||
|
{
|
||||||
|
if(SPI_FLASH_BUF[secoff+i]!=0XFF)break; //需要擦除
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i<secremain) //需要擦除
|
||||||
|
{
|
||||||
|
SPI_Flash_Erase_Sector(secpos); //擦除这个扇区
|
||||||
|
|
||||||
|
for(i=0;i<secremain;i++) //复制
|
||||||
|
{
|
||||||
|
SPI_FLASH_BUF[i+secoff]=pBuffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
SPI_Flash_Write_NoCheck(SPI_FLASH_BUF,secpos*4096,4096); //写入整个扇区
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SPI_Flash_Write_NoCheck(pBuffer,WriteAddr,secremain); //写已经擦除了的,直接写入扇区剩余空间
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size==secremain)
|
||||||
|
{
|
||||||
|
break; //写入结束
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
secpos++; //扇区地址增1
|
||||||
|
secoff=0; //偏移位置为0
|
||||||
|
|
||||||
|
pBuffer+=secremain; //指针偏移
|
||||||
|
WriteAddr+=secremain; //写地址偏移
|
||||||
|
size-=secremain; //字节数递减
|
||||||
|
|
||||||
|
if(size>4096)
|
||||||
|
{
|
||||||
|
secremain=4096; //下一个扇区还是写不完
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
secremain=size; //下一个扇区可以写完了
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_Erase_Chip
|
||||||
|
* Description : Erase all FLASH pages.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_Erase_Chip(void)
|
||||||
|
{
|
||||||
|
SPI_FLASH_Write_Enable();
|
||||||
|
SPI_Flash_Wait_Busy();
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_ChipErase); //发送片擦除指令
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
SPI_Flash_Wait_Busy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_PowerDown
|
||||||
|
* Description : Enter power down mode.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_PowerDown(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_PowerDown); //发送进入断电模式之灵
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
delay_us(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
* Function Name : SPI_Flash_WAKEUP
|
||||||
|
* Description : Power down wake up.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
*******************************************************************************/
|
||||||
|
void SPI_Flash_WAKEUP(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 0);
|
||||||
|
SPI_ReadWriteByte(W25X_ReleasePowerDown); //发送断电唤醒指令
|
||||||
|
GPIO_WriteBit(CS_GPIO, CS_PIN, 1);
|
||||||
|
delay_us(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPI_Flash_TEST(void)
|
||||||
|
{
|
||||||
|
const int SIZE = 100;
|
||||||
|
u8 TEXT_Buf[100] = "hello world \n";
|
||||||
|
u8 datap[SIZE];
|
||||||
|
u16 Flash_Model;
|
||||||
|
SPI_Flash_Init();
|
||||||
|
Flash_Model = SPI_Flash_ReadID();
|
||||||
|
log_info("SPI_Flash_ReadID = %x \n", Flash_Model);
|
||||||
|
switch(Flash_Model)
|
||||||
|
{
|
||||||
|
case W25Q80:
|
||||||
|
log_info("W25Q80 OK!\r\n");
|
||||||
|
break;
|
||||||
|
case W25Q16:
|
||||||
|
log_info("W25Q16 OK!\r\n");
|
||||||
|
break;
|
||||||
|
case W25Q32:
|
||||||
|
log_info("W25Q32 OK!\r\n");
|
||||||
|
break;
|
||||||
|
case W25Q64:
|
||||||
|
log_info("W25Q64 OK!\r\n");
|
||||||
|
break;
|
||||||
|
case W25Q128:
|
||||||
|
log_info("W25Q128 OK!\r\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_info("Fail!\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("Start Erase W25Qxx....\r\n");
|
||||||
|
SPI_Flash_Erase_Sector(0);
|
||||||
|
log_info("W25Qxx Erase Finished!\r\n");
|
||||||
|
|
||||||
|
delay_us(500);
|
||||||
|
log_info("Start Write W25Qxx....\r\n");
|
||||||
|
SPI_Flash_Write((u8*)TEXT_Buf,0,SIZE);
|
||||||
|
log_info("W25Qxx Write Finished!\r\n");
|
||||||
|
|
||||||
|
delay_us(500);
|
||||||
|
log_info("Start Read W25Qxx....\r\n");
|
||||||
|
SPI_Flash_Read(datap,0x0,SIZE);
|
||||||
|
log_info("READ:%s\r\n", datap );
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
#include "HD_GPIO.h"
|
||||||
|
|
||||||
|
void HD_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
|
||||||
|
/* 安卓模块电源使能引脚,默认不使能 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_Init(GPIO_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(GPIO_PwrCtrl_GPIO_PROT, GPIO_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
/* 复位安卓模块引脚,默认低电平 */
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_PwrKey_GPIO_PIN;
|
||||||
|
GPIO_Init(GPIO_PwrKey_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(GPIO_PwrKey_GPIO_PROT, GPIO_PwrKey_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
/* 电源控制引脚,默认不开启电源 */
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J1_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J1_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J1_PwrCtrl_GPIO_PROT, J1_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J2_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J2_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J2_PwrCtrl_GPIO_PROT, J2_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J3_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J3_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J3_PwrCtrl_GPIO_PROT, J3_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J4_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J4_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J4_PwrCtrl_GPIO_PROT, J4_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J5_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J5_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J5_PwrCtrl_GPIO_PROT, J5_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J6_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J6_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J6_PwrCtrl_GPIO_PROT, J6_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J7_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J7_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J7_PwrCtrl_GPIO_PROT, J7_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J8_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J8_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J8_PwrCtrl_GPIO_PROT, J8_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J9_PwrCtrl_GPIO_PIN;
|
||||||
|
GPIO_Init(J9_PwrCtrl_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(J9_PwrCtrl_GPIO_PROT, J9_PwrCtrl_GPIO_PIN, Bit_RESET);
|
||||||
|
|
||||||
|
/* 喂狗引脚 */
|
||||||
|
GPIO_InitStructure.GPIO_Pin = WDI_GPIO_PIN;
|
||||||
|
GPIO_Init(WDI_GPIO_PROT, &GPIO_InitStructure);
|
||||||
|
GPIO_WriteBit(WDI_GPIO_PROT, WDI_GPIO_PIN, Bit_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 设置IO输出电平
|
||||||
|
* @param GPIOx
|
||||||
|
GPIO_Pin
|
||||||
|
BitVal
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
void HD_GPIO_Write(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin, BitOperation BitVal)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(GPIOx, GPIO_Pin, BitVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到IO电平
|
||||||
|
* @param GPIOx
|
||||||
|
GPIO_Pin
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
uint8_t HD_InputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin)
|
||||||
|
{
|
||||||
|
return GPIO_ReadInputDataBit(GPIOx, GPIO_Pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 得到IO电平
|
||||||
|
* @param GPIOx
|
||||||
|
GPIO_Pin
|
||||||
|
* @retval
|
||||||
|
*/
|
||||||
|
uint8_t HD_OutputGPIO_Read(GPIOTypeDef *GPIOx, GPIOPin GPIO_Pin)
|
||||||
|
{
|
||||||
|
return GPIO_ReadOutputDataBit(GPIOx, GPIO_Pin);
|
||||||
|
}
|
|
@ -0,0 +1,562 @@
|
||||||
|
#include "HD_UART.h"
|
||||||
|
|
||||||
|
void USART2_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
void USART3_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
#ifdef uart4_enable
|
||||||
|
// void UART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
|
void UART4_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
#endif
|
||||||
|
void UART5_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
void UART6_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
void UART7_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
void UART8_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
|
||||||
|
#define write Bit_SET
|
||||||
|
#define read Bit_RESET
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始化UART6对应的J1_485,默认为接收
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void J1_485_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
/* 初始化DE引脚 */
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J1_DE_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(J1_DE_PROT, &GPIO_InitStructure);
|
||||||
|
readJ1_485;
|
||||||
|
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* UART6 TX --> PC0 RX --> PC1 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART6, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PC0为复用推挽输出
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PC1为浮空输入
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(UART6, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = UART6_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //抢占优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(UART6, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(UART6,ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始化UART7对应的J2_485,默认为接收,电源关闭状态
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void J2_485_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
/* 初始化DE引脚 */
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J2_DE_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(J2_DE_PROT, &GPIO_InitStructure);
|
||||||
|
readJ2_485;
|
||||||
|
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* UART7 TX --> PC2 RX --> PC3 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART7, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PC2为复用推挽输出
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PC3为浮空输入
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(UART7, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = UART7_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //抢占优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(UART7, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(UART7,ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始化USART2对应的J3_485,默认为接收,电源关闭状态
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void J3_485_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
/* 初始化DE引脚 */
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J3_DE_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(J3_DE_PROT, &GPIO_InitStructure);
|
||||||
|
readJ3_485;
|
||||||
|
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* USART2 TX --> PA2 RX --> PA3 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PA2为复用推挽输出
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PA3为浮空输入
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(USART2, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //抢占优先级为1
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为1
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(USART2,ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始化UART8对应的J4_485,默认为接收,电源关闭状态
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void J4_485_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
/* 初始化DE引脚 */
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J4_DE_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(J4_DE_PROT, &GPIO_InitStructure);
|
||||||
|
readJ4_485;
|
||||||
|
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* UART8 TX --> PC4 RX --> PC5 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART8, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PC4为复用推挽输出
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PC5为浮空输入
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(UART8, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = UART8_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //抢占优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(UART8, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(UART8,ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始话USART3用于控制J5-0共6个485接口,设置控制的485为J0,电源全部关闭
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void J5_0_485_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
/* 初始化DE引脚 */
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J5_0_DE_PIN;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
readJ5_0_485;
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J5_0_A_PIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J5_0_B_PIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
GPIO_InitStructure.GPIO_Pin = J5_0_C_PIN;
|
||||||
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
USART_CONNET_J0();
|
||||||
|
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* USART3 TX --> PB10 RX --> PB11 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PB10为复用推挽输出
|
||||||
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PB11为浮空输入
|
||||||
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(USART3, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1; //抢占优先级为1
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //子优先级为1
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||||
|
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(USART3,ENABLE);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J0
|
||||||
|
* Description : 控制串口3连接J0对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J0(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J5
|
||||||
|
* Description : 控制串口3连接J5对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J5(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J6
|
||||||
|
* Description : 控制串口3连接J6对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J6(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_SET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J7
|
||||||
|
* Description : 控制串口3连接J7对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J7(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_SET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J8
|
||||||
|
* Description : 控制串口3连接J8对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J8(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_SET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Name : USART_CONNET_J9
|
||||||
|
* Description : 控制串口3连接J9对应的485.
|
||||||
|
* Input : None
|
||||||
|
* Return : None
|
||||||
|
**/
|
||||||
|
void USART_CONNET_J9(void)
|
||||||
|
{
|
||||||
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_SET);
|
||||||
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
||||||
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef uart4_enable
|
||||||
|
/*
|
||||||
|
* @brief 初始化UART4对应的LORA串口
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void LORA_UART4_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* UART4 TX --> PC10 RX --> PC11 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PC10为复用推挽输出
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PC11为浮空输入
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(UART4, &USART_InitStructure);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //抢占优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
USART_Cmd(UART4,ENABLE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 初始化UART5对应的对上串口
|
||||||
|
* @param baud 波特率
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void Upward_UART5_Init(uint32_t baud)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
USART_InitTypeDef USART_InitStructure;
|
||||||
|
NVIC_InitTypeDef NVIC_InitStructure;
|
||||||
|
|
||||||
|
/* UART5 TX --> PC12 RX --> PD2 */
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||||
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
||||||
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
|
||||||
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //设置PC12为复用推挽输出
|
||||||
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
||||||
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PD2为浮空输入
|
||||||
|
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
USART_InitStructure.USART_BaudRate = baud;
|
||||||
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||||
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||||
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||||
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
||||||
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
||||||
|
USART_Init(UART5, &USART_InitStructure);
|
||||||
|
|
||||||
|
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
|
||||||
|
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn;
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1; //抢占优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级为3
|
||||||
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
|
||||||
|
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||||
|
|
||||||
|
USART_Cmd(UART5,ENABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void USART2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
J3_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void USART3_IRQHandler(void)
|
||||||
|
{
|
||||||
|
J5_0_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef uart4_enable
|
||||||
|
void UART4_IRQHandler(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UART5_IRQHandler(void)
|
||||||
|
{
|
||||||
|
Upward_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UART6_IRQHandler(void)
|
||||||
|
{
|
||||||
|
J1_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UART7_IRQHandler(void)
|
||||||
|
{
|
||||||
|
J2_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UART8_IRQHandler(void)
|
||||||
|
{
|
||||||
|
J4_Interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 发送一个字符
|
||||||
|
* @param pUSARTx 串口
|
||||||
|
data 字符
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data)
|
||||||
|
{
|
||||||
|
while(USART_GetFlagStatus(pUSARTx, USART_FLAG_TXE) == RESET) /* waiting for sending finish */
|
||||||
|
{
|
||||||
|
}
|
||||||
|
USART_SendData(pUSARTx, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief 发送字符串
|
||||||
|
* @param pUSARTx 串口
|
||||||
|
data 字符
|
||||||
|
len 发送字符串的长度
|
||||||
|
* @retval
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void USARTx_SendStr_Len(USART_TypeDef* pUSARTx, char *str, int len)
|
||||||
|
{
|
||||||
|
if (pUSARTx == J1_USART) {
|
||||||
|
writeJ1_485;
|
||||||
|
} else if (pUSARTx == J2_USART) {
|
||||||
|
writeJ2_485;
|
||||||
|
} else if (pUSARTx == J3_USART) {
|
||||||
|
writeJ3_485;
|
||||||
|
} else if (pUSARTx == J4_USART) {
|
||||||
|
writeJ4_485;
|
||||||
|
} else if (pUSARTx == J5_0_USART) {
|
||||||
|
writeJ5_0_485;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
USARTx_SendByte(pUSARTx, str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pUSARTx == J1_USART) {
|
||||||
|
readJ1_485;
|
||||||
|
} else if (pUSARTx == J2_USART) {
|
||||||
|
readJ2_485;
|
||||||
|
} else if (pUSARTx == J3_USART) {
|
||||||
|
readJ3_485;
|
||||||
|
} else if (pUSARTx == J4_USART) {
|
||||||
|
readJ4_485;
|
||||||
|
} else if (pUSARTx == J5_0_USART) {
|
||||||
|
readJ5_0_485;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
typedef unsigned long int ulong;
|
typedef unsigned long int ulong;
|
||||||
typedef unsigned short int ushort;
|
typedef unsigned short int ushort;
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned char u_int8_t;
|
// typedef unsigned char u_int8_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short int u_int16_t;
|
// typedef unsigned short int u_int16_t;
|
||||||
typedef unsigned short int uint16_t;
|
typedef unsigned short int uint16_t;
|
||||||
typedef unsigned int u_int32_t;
|
// typedef unsigned int u_int32_t;
|
||||||
typedef unsigned int uint32_t;
|
// typedef unsigned int uint32_t;
|
||||||
typedef unsigned long long u_int64_t;
|
// typedef unsigned long long u_int64_t;
|
||||||
typedef unsigned long long uint64_t;
|
typedef unsigned long long uint64_t;
|
||||||
typedef unsigned char BOOL;
|
typedef unsigned char BOOL;
|
||||||
typedef float float_t;
|
typedef float float_t;
|
||||||
|
|
|
@ -29,9 +29,13 @@
|
||||||
#define log_warn(M, ...) do {}while(0)
|
#define log_warn(M, ...) do {}while(0)
|
||||||
#define log_info(M, ...) do {}while(0)
|
#define log_info(M, ...) do {}while(0)
|
||||||
#else
|
#else
|
||||||
#define log_info(M, ...) {if(log_info_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
// #define log_info(M, ...) {if(log_info_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
// #define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
// #define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); debug_printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
||||||
|
|
||||||
|
#define log_info(M, ...) {if(log_info_enable){char *p = strrchr(__FILE__, '\\'); printf("[INFO] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
|
#define log_warn(M, ...) {if(log_warn_enable){char *p = strrchr(__FILE__, '\\'); printf("[WARN] [%s:%d] " M "\r\n", p+1, __LINE__, ##__VA_ARGS__);}}
|
||||||
|
#define log_error(M, ...) {if(log_error_enable){char *p = strrchr(__FILE__, '\\'); printf("[ERROR] [%s:%d] " M "\r\n", p+1, __LINE__,##__VA_ARGS__);}}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -127,7 +127,9 @@
|
||||||
"${project}/FreeRTOS/portable/MemMang",
|
"${project}/FreeRTOS/portable/MemMang",
|
||||||
"${project}/App/hardwareDriver/Inc",
|
"${project}/App/hardwareDriver/Inc",
|
||||||
"${project}/App/tools",
|
"${project}/App/tools",
|
||||||
"${project}/App/tools/RingQueue"
|
"${project}/App/tools/RingQueue",
|
||||||
|
"${project}/App",
|
||||||
|
"${project}/App/functionalModule/Inc"
|
||||||
],
|
],
|
||||||
"include_system_paths": [],
|
"include_system_paths": [],
|
||||||
"include_files": []
|
"include_files": []
|
||||||
|
@ -159,7 +161,12 @@
|
||||||
"${project}/FreeRTOS/portable/Common",
|
"${project}/FreeRTOS/portable/Common",
|
||||||
"${project}/FreeRTOS/portable/GCC/RISC-V",
|
"${project}/FreeRTOS/portable/GCC/RISC-V",
|
||||||
"${project}/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions",
|
"${project}/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions",
|
||||||
"${project}/FreeRTOS/portable/MemMang"
|
"${project}/FreeRTOS/portable/MemMang",
|
||||||
|
"${project}/App/hardwareDriver/Inc",
|
||||||
|
"${project}/App/tools",
|
||||||
|
"${project}/App/tools/RingQueue",
|
||||||
|
"${project}/App/functionalModule/Inc",
|
||||||
|
"${project}/App/application/Inc"
|
||||||
],
|
],
|
||||||
"include_system_paths": [],
|
"include_system_paths": [],
|
||||||
"include_files": []
|
"include_files": []
|
||||||
|
@ -718,10 +725,8 @@
|
||||||
"ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2,
|
"ATTR_BUILD_BEFORE_LAUNCH_ATTR": 2,
|
||||||
"GdbServerAllocateConsole": true,
|
"GdbServerAllocateConsole": true,
|
||||||
"GdbServerAllocateTelnetConsole": false,
|
"GdbServerAllocateTelnetConsole": false,
|
||||||
"SkipDownloadBeforeDebug": false,
|
|
||||||
"StartGdbCLient": true,
|
"StartGdbCLient": true,
|
||||||
"UPDATE_THREADLIST_ON_SUSPEND": false,
|
"UPDATE_THREADLIST_ON_SUSPEND": false
|
||||||
"DebugInRam": false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1 +1,186 @@
|
||||||
ENTRY( _start )
__stack_size = 2048;
PROVIDE( _stack_size = __stack_size );
MEMORY
{
/* CH32V30x_D8C - CH32V305RB-CH32V305FB
CH32V30x_D8 - CH32V303CB-CH32V303RB
*/
/**/
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
/* CH32V30x_D8C - CH32V307VC-CH32V307WC-CH32V307RC-CH32V305CC
CH32V30x_D8 - CH32V303VC-CH32V303RC
FLASH + RAM supports the following configuration
For specific choices, please refer :CH32FV2x_V3xRM.PDF\Table 32-3
FLASH-192K + RAM-128K
FLASH-224K + RAM-96K
FLASH-256K + RAM-64K
FLASH-288K + RAM-32K
FLASH-128K + RAM-192K
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 288K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K*/
}
SECTIONS
{
.init :
{
_sinit = .;
. = ALIGN(4);
KEEP(*(SORT_NONE(.init)))
. = ALIGN(4);
_einit = .;
} >FLASH AT>FLASH
.vector :
{
*(.vector);
. = ALIGN(64);
} >FLASH AT>FLASH
.text :
{
. = ALIGN(4);
*(.text)
*(.text.*)
*(.rodata)
*(.rodata*)
*(.gnu.linkonce.t.*)
. = ALIGN(4);
} >FLASH AT>FLASH
.fini :
{
KEEP(*(SORT_NONE(.fini)))
. = ALIGN(4);
} >FLASH AT>FLASH
PROVIDE( _etext = . );
PROVIDE( _eitcm = . );
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH AT>FLASH
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH AT>FLASH
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH AT>FLASH
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >FLASH AT>FLASH
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >FLASH AT>FLASH
.dalign :
{
. = ALIGN(4);
PROVIDE(_data_vma = .);
} >RAM AT>FLASH
.dlalign :
{
. = ALIGN(4);
PROVIDE(_data_lma = .);
} >FLASH AT>FLASH
.data :
{
*(.gnu.linkonce.r.*)
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.*)
*(.sdata2.*)
*(.gnu.linkonce.s.*)
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
. = ALIGN(4);
PROVIDE( _edata = .);
} >RAM AT>FLASH
.bss :
{
. = ALIGN(4);
PROVIDE( _sbss = .);
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss*)
*(.gnu.linkonce.b.*)
*(COMMON*)
. = ALIGN(4);
PROVIDE( _ebss = .);
} >RAM AT>FLASH
PROVIDE( _end = _ebss);
PROVIDE( end = . );
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
{
PROVIDE( _heap_end = . );
. = ALIGN(4);
PROVIDE(_susrstack = . );
. = . + __stack_size;
PROVIDE( _eusrstack = .);
__freertos_irq_stack_top = .;
} >RAM
}
|
ENTRY( _start )
|
||||||
|
|
||||||
|
__stack_size = 2048;
|
||||||
|
|
||||||
|
PROVIDE( _stack_size = __stack_size );
|
||||||
|
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* CH32V30x_D8C - CH32V305RB-CH32V305FB
|
||||||
|
CH32V30x_D8 - CH32V303CB-CH32V303RB
|
||||||
|
*/
|
||||||
|
/**/
|
||||||
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K
|
||||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||||
|
|
||||||
|
|
||||||
|
/* CH32V30x_D8C - CH32V307VC-CH32V307WC-CH32V307RC-CH32V305CC
|
||||||
|
CH32V30x_D8 - CH32V303VC-CH32V303RC
|
||||||
|
FLASH + RAM supports the following configuration
|
||||||
|
For specific choices, please refer :CH32FV2x_V3xRM.PDF\Table 32-3
|
||||||
|
FLASH-192K + RAM-128K
|
||||||
|
FLASH-224K + RAM-96K
|
||||||
|
FLASH-256K + RAM-64K
|
||||||
|
FLASH-288K + RAM-32K
|
||||||
|
FLASH-128K + RAM-192K
|
||||||
|
|
||||||
|
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 288K
|
||||||
|
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
|
||||||
|
.init :
|
||||||
|
{
|
||||||
|
_sinit = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
KEEP(*(SORT_NONE(.init)))
|
||||||
|
. = ALIGN(4);
|
||||||
|
_einit = .;
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.vector :
|
||||||
|
{
|
||||||
|
*(.vector);
|
||||||
|
. = ALIGN(64);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
*(.text)
|
||||||
|
*(.text.*)
|
||||||
|
*(.rodata)
|
||||||
|
*(.rodata*)
|
||||||
|
*(.gnu.linkonce.t.*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.fini :
|
||||||
|
{
|
||||||
|
KEEP(*(SORT_NONE(.fini)))
|
||||||
|
. = ALIGN(4);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
PROVIDE( _etext = . );
|
||||||
|
PROVIDE( _eitcm = . );
|
||||||
|
|
||||||
|
.preinit_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||||
|
KEEP (*(.preinit_array))
|
||||||
|
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.init_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||||
|
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.fini_array :
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||||
|
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||||
|
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||||
|
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.ctors :
|
||||||
|
{
|
||||||
|
/* gcc uses crtbegin.o to find the start of
|
||||||
|
the constructors, so we make sure it is
|
||||||
|
first. Because this is a wildcard, it
|
||||||
|
doesn't matter if the user does not
|
||||||
|
actually link against crtbegin.o; the
|
||||||
|
linker won't look for a file to match a
|
||||||
|
wildcard. The wildcard also means that it
|
||||||
|
doesn't matter which directory crtbegin.o
|
||||||
|
is in. */
|
||||||
|
KEEP (*crtbegin.o(.ctors))
|
||||||
|
KEEP (*crtbegin?.o(.ctors))
|
||||||
|
/* We don't want to include the .ctor section from
|
||||||
|
the crtend.o file until after the sorted ctors.
|
||||||
|
The .ctor section from the crtend file contains the
|
||||||
|
end of ctors marker and it must be last */
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
|
||||||
|
KEEP (*(SORT(.ctors.*)))
|
||||||
|
KEEP (*(.ctors))
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.dtors :
|
||||||
|
{
|
||||||
|
KEEP (*crtbegin.o(.dtors))
|
||||||
|
KEEP (*crtbegin?.o(.dtors))
|
||||||
|
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
|
||||||
|
KEEP (*(SORT(.dtors.*)))
|
||||||
|
KEEP (*(.dtors))
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.dalign :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE(_data_vma = .);
|
||||||
|
} >RAM AT>FLASH
|
||||||
|
|
||||||
|
.dlalign :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE(_data_lma = .);
|
||||||
|
} >FLASH AT>FLASH
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.gnu.linkonce.r.*)
|
||||||
|
*(.data .data.*)
|
||||||
|
*(.gnu.linkonce.d.*)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE( __global_pointer$ = . + 0x800 );
|
||||||
|
*(.sdata .sdata.*)
|
||||||
|
*(.sdata2.*)
|
||||||
|
*(.gnu.linkonce.s.*)
|
||||||
|
. = ALIGN(8);
|
||||||
|
*(.srodata.cst16)
|
||||||
|
*(.srodata.cst8)
|
||||||
|
*(.srodata.cst4)
|
||||||
|
*(.srodata.cst2)
|
||||||
|
*(.srodata .srodata.*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE( _edata = .);
|
||||||
|
} >RAM AT>FLASH
|
||||||
|
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE( _sbss = .);
|
||||||
|
*(.sbss*)
|
||||||
|
*(.gnu.linkonce.sb.*)
|
||||||
|
*(.bss*)
|
||||||
|
*(.gnu.linkonce.b.*)
|
||||||
|
*(COMMON*)
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE( _ebss = .);
|
||||||
|
} >RAM AT>FLASH
|
||||||
|
|
||||||
|
PROVIDE( _end = _ebss);
|
||||||
|
PROVIDE( end = . );
|
||||||
|
|
||||||
|
.stack ORIGIN(RAM) + LENGTH(RAM) - __stack_size :
|
||||||
|
{
|
||||||
|
PROVIDE( _heap_end = . );
|
||||||
|
. = ALIGN(4);
|
||||||
|
PROVIDE(_susrstack = . );
|
||||||
|
. = . + __stack_size;
|
||||||
|
PROVIDE( _eusrstack = .);
|
||||||
|
__freertos_irq_stack_top = .;
|
||||||
|
} >RAM
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ handle_reset:
|
||||||
csrw 0xbc0, t0
|
csrw 0xbc0, t0
|
||||||
/* Enable interrupt nesting and hardware stack */
|
/* Enable interrupt nesting and hardware stack */
|
||||||
li t0, 0x1f
|
li t0, 0x1f
|
||||||
|
// li t0, 0x1e
|
||||||
csrw 0x804, t0
|
csrw 0x804, t0
|
||||||
/* Enable floating point and global interrupt, configure privileged mode */
|
/* Enable floating point and global interrupt, configure privileged mode */
|
||||||
li t0, 0x7800
|
li t0, 0x7800
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
#include "freerotsTask.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
|
@ -39,6 +41,7 @@ int main(void)
|
||||||
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
|
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID() );
|
||||||
printf("FreeRTOS Kernel Version:%s\r\n", tskKERNEL_VERSION_NUMBER);
|
printf("FreeRTOS Kernel Version:%s\r\n", tskKERNEL_VERSION_NUMBER);
|
||||||
|
|
||||||
|
startApp();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
printf("shouldn't run at here!!\n");
|
printf("shouldn't run at here!!\n");
|
||||||
|
|
|
@ -17,4 +17,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
App/tools/RingQueue/%.o: ../App/tools/RingQueue/%.c
|
App/tools/RingQueue/%.o: ../App/tools/RingQueue/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -17,4 +17,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
Core/%.o: ../Core/%.c
|
Core/%.o: ../Core/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -17,4 +17,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
Debug/%.o: ../Debug/%.c
|
Debug/%.o: ../Debug/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -24,6 +24,6 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
FreeRTOS/portable/GCC/RISC-V/%.o: ../FreeRTOS/portable/GCC/RISC-V/%.c
|
FreeRTOS/portable/GCC/RISC-V/%.o: ../FreeRTOS/portable/GCC/RISC-V/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
FreeRTOS/portable/GCC/RISC-V/%.o: ../FreeRTOS/portable/GCC/RISC-V/%.S
|
FreeRTOS/portable/GCC/RISC-V/%.o: ../FreeRTOS/portable/GCC/RISC-V/%.S
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -x assembler-with-cpp -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Startup" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -x assembler-with-cpp -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Startup" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -17,4 +17,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
FreeRTOS/portable/MemMang/%.o: ../FreeRTOS/portable/MemMang/%.c
|
FreeRTOS/portable/MemMang/%.o: ../FreeRTOS/portable/MemMang/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -35,4 +35,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
FreeRTOS/%.o: ../FreeRTOS/%.c
|
FreeRTOS/%.o: ../FreeRTOS/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -92,4 +92,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
Peripheral/src/%.o: ../Peripheral/src/%.c
|
Peripheral/src/%.o: ../Peripheral/src/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -17,4 +17,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
Startup/%.o: ../Startup/%.S
|
Startup/%.o: ../Startup/%.S
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -x assembler-with-cpp -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Startup" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -x assembler-with-cpp -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Startup" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -36,7 +36,9 @@ User/main.o: ../User/main.c \
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/portmacro.h \
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/portmacro.h \
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/mpu_wrappers.h \
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/mpu_wrappers.h \
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/task.h \
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/task.h \
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/list.h
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/list.h \
|
||||||
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc/freerotsTask.h \
|
||||||
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/pDebug.h
|
||||||
|
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug/debug.h:
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug/debug.h:
|
||||||
|
|
||||||
|
@ -113,3 +115,7 @@ d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/mpu_wrappers.
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/task.h:
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/task.h:
|
||||||
|
|
||||||
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/list.h:
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include/list.h:
|
||||||
|
|
||||||
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc/freerotsTask.h:
|
||||||
|
|
||||||
|
d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/pDebug.h:
|
||||||
|
|
Binary file not shown.
|
@ -23,4 +23,4 @@ OBJS += \
|
||||||
|
|
||||||
# Each subdirectory must supply rules for building sources it contributes
|
# Each subdirectory must supply rules for building sources it contributes
|
||||||
User/%.o: ../User/%.c
|
User/%.o: ../User/%.c
|
||||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Debug" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Core" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/User" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Peripheral/inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/include" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/Common" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/GCC/RISC-V/chip_specific_extensions/RV32I_PFIC_no_extensions" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/FreeRTOS/portable/MemMang" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/hardwareDriver/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/tools/RingQueue" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/functionalModule/Inc" -I"d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/App/application/Inc" -std=gnu99 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -c -o "$@" "$<"
|
||||||
|
|
|
@ -17,6 +17,9 @@ RM := rm -rf
|
||||||
-include Debug/subdir.mk
|
-include Debug/subdir.mk
|
||||||
-include Core/subdir.mk
|
-include Core/subdir.mk
|
||||||
-include App/tools/RingQueue/subdir.mk
|
-include App/tools/RingQueue/subdir.mk
|
||||||
|
-include App/hardwareDriver/Src/subdir.mk
|
||||||
|
-include App/functionalModule/Src/subdir.mk
|
||||||
|
-include App/application/Src/subdir.mk
|
||||||
-include subdir.mk
|
-include subdir.mk
|
||||||
-include objects.mk
|
-include objects.mk
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@ SECONDARY_SIZE :=
|
||||||
|
|
||||||
# Every subdirectory with source files must be described here
|
# Every subdirectory with source files must be described here
|
||||||
SUBDIRS := \
|
SUBDIRS := \
|
||||||
|
App/application/Src \
|
||||||
|
App/functionalModule/Src \
|
||||||
|
App/hardwareDriver/Src \
|
||||||
App/tools/RingQueue \
|
App/tools/RingQueue \
|
||||||
Core \
|
Core \
|
||||||
Debug \
|
Debug \
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
### 测试
|
||||||
|
|
||||||
|
串口中断发送通过测试
|
||||||
|
|
||||||
|
spi_flash读写通过测试
|
||||||
|
|
||||||
|
对智能模块通信串口,阻塞发送数据通过测试。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### 问题
|
||||||
|
|
||||||
|
##### 串口中断
|
||||||
|
|
||||||
|
25/02/24
|
||||||
|
|
||||||
|
在freerots环境下,中断不生效
|
||||||
|
|
||||||
|
###### 解决
|
||||||
|
|
||||||
|
> 25/02/25
|
||||||
|
>
|
||||||
|
> 需要启动freerots任务
|
||||||
|
>
|
||||||
|
> 同时中断部分
|
||||||
|
>
|
||||||
|
> ```c
|
||||||
|
> void UART5_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> 变为
|
||||||
|
>
|
||||||
|
> ```c
|
||||||
|
> void UART5_IRQHandler(void) __attribute__((interrupt()));
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> 其他中断同上,由硬件压栈变为软件压栈
|
||||||
|
|
Loading…
Reference in New Issue