1、初始程序
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
#ifndef __ADS1231__
|
||||
#define __ADS1231__
|
||||
|
||||
#include "bsp.h"
|
||||
|
||||
void ADS1231_Open(void);
|
||||
void ADS1231_SpeedSet(void);
|
||||
bool ADS1231_Read(uint32_t *r_data, uint8_t channel);
|
||||
void ADS1231_HighSpeedSet(void);
|
||||
void ADS1231_LowSpeedSet(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __EPT__
|
||||
#define __EPT__
|
||||
|
||||
void Encrypt_Code(unsigned char *data, unsigned char *EPT_data);
|
||||
void Decrypt_Code(unsigned char *EPT_data,unsigned char *DPT_data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,232 @@
|
||||
#ifndef __BSP_H
|
||||
#define __BSP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "hc32_ddl.h"
|
||||
|
||||
|
||||
//#define WATCH_DOG 1
|
||||
|
||||
#define DEBUG 1
|
||||
#define RS485 1
|
||||
|
||||
#define DBGUART_IRQn Int006_IRQn
|
||||
#define DBGUART_EI_IRQn Int007_IRQn
|
||||
#define DBG_RXPIN_IRQn Int002_IRQn
|
||||
|
||||
#define RS485UART_IRQn Int008_IRQn
|
||||
#define RS485UART_EI_IRQn Int009_IRQn
|
||||
#define RS485_RXPIN_IRQn Int005_IRQn
|
||||
|
||||
|
||||
|
||||
#define RTC_IRQn Int001_IRQn
|
||||
|
||||
//DEBUG
|
||||
#define DBG_USART_CH (M4_USART3)
|
||||
//#define DBG_USART_RX_PORT (PortA)
|
||||
//#define DBG_USART_RX_PIN (Pin15)
|
||||
//#define DBG_USART_TX_PORT (PortA)
|
||||
//#define DBG_USART_TX_PIN (Pin12)
|
||||
#define DBG_USART_RX_PORT (PortB)
|
||||
#define DBG_USART_RX_PIN (Pin09)
|
||||
#define DBG_USART_TX_PORT (PortB)
|
||||
#define DBG_USART_TX_PIN (Pin08)
|
||||
#define DBG_USART_RX_FUNC (Func_Usart3_Rx)
|
||||
#define DBG_USART_TX_FUNC (Func_Usart3_Tx)
|
||||
#define DBG_USART_RI_NUM (INT_USART3_RI)
|
||||
#define DBG_USART_EI_NUM (INT_USART3_EI)
|
||||
#define DBG_USART_TI_NUM (INT_USART3_TI)
|
||||
#define DBG_USART_TCI_NUM (INT_USART3_TCI)
|
||||
#define DBG_FCG1_PERIPH (PWC_FCG1_PERIPH_USART3)
|
||||
#define DBG_RXPIN_EXIT_CH (ExtiCh13)
|
||||
#define DBG_RXPIN_EXIT_SRC (INT_PORT_EIRQ13)
|
||||
|
||||
|
||||
//#define DBG_USART_CH (M4_USART1)
|
||||
//#define DBG_USART_RX_PORT (PortC)
|
||||
//#define DBG_USART_RX_PIN (Pin13)
|
||||
//#define DBG_USART_TX_PORT (PortH)
|
||||
//#define DBG_USART_TX_PIN (Pin02)
|
||||
//#define DBG_USART_RX_FUNC (Func_Usart1_Rx)
|
||||
//#define DBG_USART_TX_FUNC (Func_Usart1_Tx)
|
||||
//#define DBG_USART_RI_NUM (INT_USART1_RI)
|
||||
//#define DBG_USART_EI_NUM (INT_USART1_EI)
|
||||
//#define DBG_USART_TI_NUM (INT_USART1_TI)
|
||||
//#define DBG_USART_TCI_NUM (INT_USART1_TCI)
|
||||
//#define DBG_FCG1_PERIPH (PWC_FCG1_PERIPH_USART1)
|
||||
//#define DBG_RXPIN_EXIT_CH (ExtiCh13)
|
||||
//#define DBG_RXPIN_EXIT_SRC (INT_PORT_EIRQ13)
|
||||
|
||||
|
||||
|
||||
//RS485
|
||||
#define RS485_USART_CH (M4_USART1)
|
||||
//#define RS485_USART_RX_PORT (PortB)
|
||||
//#define RS485_USART_RX_PIN (Pin08)
|
||||
//#define RS485_USART_TX_PORT (PortB)
|
||||
//#define RS485_USART_TX_PIN (Pin09)
|
||||
#define RS485_USART_RX_PORT (PortA)
|
||||
#define RS485_USART_RX_PIN (Pin15)
|
||||
#define RS485_USART_TX_PORT (PortA)
|
||||
#define RS485_USART_TX_PIN (Pin12)
|
||||
#define RS485_USART_RX_FUNC (Func_Usart1_Rx)
|
||||
#define RS485_USART_TX_FUNC (Func_Usart1_Tx)
|
||||
#define RS485_USART_RI_NUM (INT_USART1_RI)
|
||||
#define RS485_USART_EI_NUM (INT_USART1_EI)
|
||||
#define RS485_USART_TI_NUM (INT_USART1_TI)
|
||||
#define RS485_USART_TCI_NUM (INT_USART1_TCI)
|
||||
#define RS485_FCG1_PERIPH (PWC_FCG1_PERIPH_USART1)
|
||||
#define RS485_RXPIN_EXIT_CH (ExtiCh14)
|
||||
#define RS485_RXPIN_EXIT_SRC (INT_PORT_EIRQ14)
|
||||
|
||||
#define RS485_CTRL_PORT (PortC)
|
||||
#define RS485_CTRL_PIN (Pin13)
|
||||
#define RS485_TX() PORT_SetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
#define RS485_RX() PORT_ResetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
|
||||
|
||||
|
||||
|
||||
/* LED */
|
||||
#define LED_Blue_PORT (PortH)
|
||||
#define LED_Blue_PIN (Pin02)
|
||||
|
||||
#define LED_Green_PORT (PortB)
|
||||
#define LED_Green_PIN (Pin01)
|
||||
|
||||
|
||||
/* SPI_SCK Port/Pin definition */
|
||||
#define SPI_SCK_PORT (PortA)
|
||||
#define SPI_SCK_PIN (Pin05)
|
||||
#define SPI_SCK_FUNC (Func_Spi1_Sck)
|
||||
|
||||
/* SPI_MOSI Port/Pin definition */
|
||||
#define SPI_MOSI_PORT (PortA)
|
||||
#define SPI_MOSI_PIN (Pin04)
|
||||
#define SPI_MOSI_FUNC (Func_Spi1_Mosi)
|
||||
|
||||
/* SPI_MISO Port/Pin definition */
|
||||
#define SPI_MISO_PORT (PortA)
|
||||
#define SPI_MISO_PIN (Pin02)
|
||||
#define SPI_MISO_FUNC (Func_Spi1_Miso)
|
||||
|
||||
/* SPI_MOSI Port/Pin definition */
|
||||
#define SPI_NSS_PORT (PortA)
|
||||
#define SPI_NSS_PIN (Pin03)
|
||||
#define SPI_NSS_FUNC (Func_Spi1_Nss0)
|
||||
#define SPI_NSS_SET() PORT_SetBits(SPI_NSS_PORT, SPI_NSS_PIN)
|
||||
#define SPI_NSS_CLR() PORT_ResetBits(SPI_NSS_PORT, SPI_NSS_PIN)
|
||||
|
||||
/* SPI unit and clock definition */
|
||||
#define SPI_UNIT (M4_SPI1)
|
||||
#define SPI_UNIT_CLOCK (PWC_FCG1_PERIPH_SPI1)
|
||||
|
||||
//SPI3
|
||||
/* SPI3_SCK Port/Pin definition */
|
||||
#define SPI3_SCK_PORT (PortB)
|
||||
#define SPI3_SCK_PIN (Pin14)
|
||||
#define SPI3_SCK_FUNC (Func_Spi3_Sck)
|
||||
|
||||
/* SPI3_MOSI Port/Pin definition */
|
||||
#define SPI3_MOSI_PORT (PortB)
|
||||
#define SPI3_MOSI_PIN (Pin10)
|
||||
#define SPI3_MOSI_FUNC (Func_Spi3_Mosi)
|
||||
|
||||
/* SPI3_MISO Port/Pin definition */
|
||||
#define SPI3_MISO_PORT (PortB)
|
||||
#define SPI3_MISO_PIN (Pin12)
|
||||
#define SPI3_MISO_FUNC (Func_Spi3_Miso)
|
||||
|
||||
/* SPI3_MOSI Port/Pin definition */
|
||||
#define SPI3_NSS_PORT (PortB)
|
||||
#define SPI3_NSS_PIN (Pin13)
|
||||
#define SPI3_NSS_FUNC (Func_Spi3_Nss0)
|
||||
#define SPI3_NSS_SET() PORT_SetBits(SPI3_NSS_PORT, SPI3_NSS_PIN)
|
||||
#define SPI3_NSS_CLR() PORT_ResetBits(SPI3_NSS_PORT, SPI3_NSS_PIN)
|
||||
|
||||
/* SPI3 unit and clock definition */
|
||||
#define SPI3_UNIT (M4_SPI3)
|
||||
#define SPI3_UNIT_CLOCK (PWC_FCG1_PERIPH_SPI3)
|
||||
|
||||
|
||||
/* SDIOC Port/Pin definition */
|
||||
#define SDIOC_CD_PORT (PortA)
|
||||
#define SDIOC_CD_PIN (Pin10)
|
||||
|
||||
#define SDIOC_CK_PORT (PortB)
|
||||
#define SDIOC_CK_PIN (Pin15)
|
||||
|
||||
#define SDIOC_CMD_PORT (PortA)
|
||||
#define SDIOC_CMD_PIN (Pin06)
|
||||
|
||||
#define SDIOC_D0_PORT (PortB)
|
||||
#define SDIOC_D0_PIN (Pin04)
|
||||
|
||||
#define SDIOC_D1_PORT (PortA)
|
||||
#define SDIOC_D1_PIN (Pin08)
|
||||
|
||||
#define SDIOC_D2_PORT (PortA)
|
||||
#define SDIOC_D2_PIN (Pin09)
|
||||
|
||||
#define SDIOC_D3_PORT (PortB)
|
||||
#define SDIOC_D3_PIN (Pin05)
|
||||
|
||||
/* SD sector && count */
|
||||
#define SD_SECTOR_START (0u)
|
||||
#define SD_SECTOR_COUNT (4u)
|
||||
|
||||
/* SDIOC unit */
|
||||
#define SDIOC_UNIT (M4_SDIOC1)
|
||||
|
||||
|
||||
|
||||
void BSP_Init(void);
|
||||
uint8_t DbgUartRec(void);
|
||||
void DebugUartSend(uint8_t *sData, uint16_t sLen);
|
||||
void Error_Handler(void);
|
||||
void FeedDog(void);
|
||||
void EnterStop(void);
|
||||
void Wakeup(void);
|
||||
|
||||
uint8_t RS485UartRec(void);
|
||||
void RS485UsartErrIrqCallback(void);
|
||||
void RS485_RxPinIntCallBack(void);
|
||||
void RS485UsartRxIrqCallback(void);
|
||||
void RS485UartSend(uint8_t *sData, uint16_t sLen);
|
||||
|
||||
void RS485_1msRoutine(void);
|
||||
|
||||
|
||||
void DbgUsartRxIrqCallback(void);
|
||||
void DBGUsartErrIrqCallback(void);
|
||||
void DBG_RxPinIntCallBack(void);
|
||||
void SysTick_IrqHandler(void);
|
||||
void RtcPeriod_IrqCallback(void);
|
||||
uint16_t SpiSendReceive(uint16_t sData);
|
||||
|
||||
uint8_t Spi3_RWByte(M4_SPI_TypeDef *SPIx, uint8_t u8Data);
|
||||
|
||||
en_result_t SdioInit(void);
|
||||
|
||||
bool SDCardErase(uint32_t u32BlkStartAddr, uint32_t u32BlkEndAddr);
|
||||
bool SDCardReadBlocks(uint32_t u32BlkStartAddr, uint32_t u32BlkEndAddr, uint8_t *ReadBuff);
|
||||
bool SDCardWriteBlocks(uint32_t u32BlkStartAddr, uint32_t u32BlkEndAddr, uint8_t *WriteBuff);
|
||||
|
||||
void ReadAdcValue(uint16_t *ADValue);
|
||||
void ADC_Start(void) ;
|
||||
void ADC_Stop(void) ;
|
||||
uint16_t *GetADCBuffPoint(void);
|
||||
|
||||
uint8_t exf_getfree(uint8_t *drv,uint32_t *total,uint32_t *free);
|
||||
uint32_t mf_showfree(uint8_t *drv);
|
||||
|
||||
|
||||
void TimeGet(struct tm *cTime);
|
||||
int TimeTs(void);
|
||||
void TimeShow(uint32_t dwStamp);
|
||||
void TimeSync(time_t ts) ;
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by HDSC under BSD 3-Clause license
|
||||
* (the "License"); You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*/
|
||||
/******************************************************************************/
|
||||
/** \file ddl_config.h
|
||||
**
|
||||
** A detailed description is available at
|
||||
** @link DdlConfigGroup Ddl Config description @endlink
|
||||
**
|
||||
** - 2021-04-16 CDT First version for Device Driver Library config.
|
||||
**
|
||||
******************************************************************************/
|
||||
#ifndef __DDL_CONFIG_H__
|
||||
#define __DDL_CONFIG_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Include files
|
||||
******************************************************************************/
|
||||
|
||||
/* C binding of definitions if building with C++ compiler */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \defgroup DdlConfigGroup Device Driver Library config(DDLCONFIG)
|
||||
**
|
||||
******************************************************************************/
|
||||
//@{
|
||||
|
||||
/*******************************************************************************
|
||||
* Global type definitions ('typedef')
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Global pre-processor symbols/macros ('#define')
|
||||
******************************************************************************/
|
||||
/*! Chip module on-off define */
|
||||
#define DDL_ON (1u)
|
||||
#define DDL_OFF (0u)
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief This is the list of modules to be used in the device driver library
|
||||
** Select the modules you need to use to DDL_ON.
|
||||
**
|
||||
** \note DDL_ICG_ENABLE must be turned on(DDL_ON) to ensure that the chip works
|
||||
** properly.
|
||||
**
|
||||
** \note DDL_UTILITY_ENABLE must be turned on(DDL_ON) if using Device Driver
|
||||
** Library.
|
||||
**
|
||||
** \note DDL_PRINT_ENABLE must be turned on(DDL_ON) if using printf function.
|
||||
******************************************************************************/
|
||||
#define DDL_ICG_ENABLE (DDL_ON)
|
||||
#define DDL_UTILITY_ENABLE (DDL_ON)
|
||||
#define DDL_PRINT_ENABLE (DDL_OFF)
|
||||
|
||||
#define DDL_ADC_ENABLE (DDL_ON)
|
||||
#define DDL_AES_ENABLE (DDL_OFF)
|
||||
#define DDL_CAN_ENABLE (DDL_OFF)
|
||||
#define DDL_CLK_ENABLE (DDL_ON)
|
||||
#define DDL_CMP_ENABLE (DDL_OFF)
|
||||
#define DDL_CRC_ENABLE (DDL_OFF)
|
||||
#define DDL_DCU_ENABLE (DDL_OFF)
|
||||
#define DDL_DMAC_ENABLE (DDL_ON)
|
||||
#define DDL_EFM_ENABLE (DDL_ON)
|
||||
#define DDL_EMB_ENABLE (DDL_OFF)
|
||||
#define DDL_EVENT_PORT_ENABLE (DDL_OFF)
|
||||
#define DDL_EXINT_NMI_SWI_ENABLE (DDL_ON)
|
||||
#define DDL_GPIO_ENABLE (DDL_ON)
|
||||
#define DDL_HASH_ENABLE (DDL_OFF)
|
||||
#define DDL_I2C_ENABLE (DDL_OFF)
|
||||
#define DDL_I2S_ENABLE (DDL_OFF)
|
||||
#define DDL_INTERRUPTS_ENABLE (DDL_ON)
|
||||
#define DDL_INTERRUPTS_SHARE_ENABLE (DDL_OFF)
|
||||
#define DDL_KEYSCAN_ENABLE (DDL_OFF)
|
||||
#define DDL_MPU_ENABLE (DDL_OFF)
|
||||
#define DDL_OTS_ENABLE (DDL_OFF)
|
||||
#define DDL_PWC_ENABLE (DDL_ON)
|
||||
#define DDL_QSPI_ENABLE (DDL_OFF)
|
||||
#define DDL_RMU_ENABLE (DDL_OFF)
|
||||
#define DDL_RTC_ENABLE (DDL_ON)
|
||||
#define DDL_SDIOC_ENABLE (DDL_ON)
|
||||
#define DDL_SPI_ENABLE (DDL_ON)
|
||||
#define DDL_SRAM_ENABLE (DDL_ON)
|
||||
#define DDL_SWDT_ENABLE (DDL_ON)
|
||||
#define DDL_TIMER0_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER4_CNT_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER4_EMB_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER4_OCO_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER4_PWM_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER4_SEVT_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMER6_ENABLE (DDL_OFF)
|
||||
#define DDL_TIMERA_ENABLE (DDL_OFF)
|
||||
#define DDL_TRNG_ENABLE (DDL_OFF)
|
||||
#define DDL_USART_ENABLE (DDL_ON)
|
||||
#define DDL_USBFS_ENABLE (DDL_OFF)
|
||||
#define DDL_WDT_ENABLE (DDL_OFF)
|
||||
|
||||
|
||||
/*! Midware module on-off define */
|
||||
#define MW_ON (1u)
|
||||
#define MW_OFF (0u)
|
||||
|
||||
/**
|
||||
*******************************************************************************
|
||||
** \brief This is the list of Midware modules to use
|
||||
** Select the modules you need to use to MW_ON.
|
||||
******************************************************************************/
|
||||
#define MW_FS_ENABLE (MW_OFF)
|
||||
#define MW_SD_CARD_ENABLE (MW_OFF)
|
||||
#define MW_W25QXX_ENABLE (MW_OFF)
|
||||
#define MW_WM8731_ENABLE (MW_OFF)
|
||||
|
||||
/* BSP on-off define */
|
||||
#define BSP_ON (1u)
|
||||
#define BSP_OFF (0u)
|
||||
|
||||
/**
|
||||
* @brief The following is a list of currently supported BSP boards.
|
||||
*/
|
||||
#define BSP_EV_HC32F460_LQFP100_V1 (1u)
|
||||
#define BSP_EV_HC32F460_LQFP100_V2 (2u)
|
||||
|
||||
/**
|
||||
* @brief The macro BSP_EV_HC32F460 is used to specify the BSP board currently
|
||||
* in use.
|
||||
* The value should be set to one of the list of currently supported BSP boards.
|
||||
* @note If there is no supported BSP board or the BSP function is not used,
|
||||
* the value needs to be set to BSP_EV_HC32F460.
|
||||
*/
|
||||
#define BSP_EV_HC32F460 (BSP_EV_HC32F460_LQFP100_V2)
|
||||
|
||||
/*******************************************************************************
|
||||
* Global variable definitions ('extern')
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Global function prototypes (definition in C source)
|
||||
******************************************************************************/
|
||||
|
||||
//@} // DdlConfigGroup
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DDL_CONFIG_H__ */
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF (not truncated)
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef __MAIN__H
|
||||
#define __MAIN__H
|
||||
#include "bsp.h"
|
||||
|
||||
|
||||
#define USE_FILE_SYSTEM 1
|
||||
#define SDCARD_BLOCK_MAX (10000)
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t Acc[3];
|
||||
uint16_t SensorValue[4];
|
||||
}SendData_t, *SendData;
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t ADValue[4];
|
||||
uint16_t Index;
|
||||
}SaveData_t, *SaveData;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user