Commit 8c26bdd8 authored by 郑萍's avatar 郑萍

🎉 init:更换adc采集和adc驱动

parent 89edae4e
......@@ -4,7 +4,7 @@
* \attention
*
* This file is automatically generated by analog signals configuration tool.
* Date : 2024/3/31 13:14:40
* Date : 2024/6/16 16:49:27
* Cfg Tool Ver : 1.1.0
* Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD
......@@ -15,7 +15,7 @@
#include "Analog_Signals.h"
/* Private typedef ----------------------------------------------------------*/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint8_t u8Ch;
uint8_t u8RefType;
......@@ -26,7 +26,7 @@ typedef struct
ADC_Circuit_Calc_Func pfProcFunc;
}ADC_Ch_Cfg_st_t;
typedef enum ASigConvStat
typedef __attribute__((aligned(4))) enum ASigConvStat
{
ADC_STAT_IDLE = 0,
ADC_STAT_INIT,
......@@ -36,7 +36,7 @@ typedef enum ASigConvStat
ADC_STAT_ERR,
}ADC_Stat_en_t;
typedef struct
typedef struct __attribute__((aligned(4)))
{
ADC_Stat_en_t enStatus;
uint8_t u8CurrentCh;
......@@ -44,7 +44,7 @@ typedef struct
uint8_t u8Timer;
}ADC_Ctrl_st_t;
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint8_t u8Valid;
uint8_t u8Rsvd;
......@@ -72,25 +72,21 @@ ADC_Ctrl_st_t stADCCtrl;
uint16_t u16ADCSample[ADC_CONV_CH_NUMBER];
ADC_Data_st_t stADCData[ADC_SIGNAL_CH_NUMBER];
const uint8_t u8ADCChList[ADC_CONV_CH_NUMBER] =
const uint8_t __attribute__((aligned(4))) u8ADCChList[ADC_CONV_CH_NUMBER] =
{
2U, 3U, 7U, 5U,
2U, 3U,
};
const ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] =
const __attribute__((aligned(4))) ADC_Ch_Cfg_st_t stADCChCfg[ADC_SIGNAL_CH_NUMBER] =
{
{ 0U, 0U, 0U, 0U, 700U, 1U, ADC_Voltage_Calc_Circuit102,},
{ 0U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit102,},
{ 1U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit102,},
{ 2U, 0U, 0U, 0U, 0U, 1U, ADC_Voltage_Calc_Circuit101,},
{ 3U, 2U, 0U, 2U, 18U, 1U, ADC_Res_Calc_Circuit101,},
};
const ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] =
const __attribute__((aligned(4))) ADC_Res_List_st_t stADCResList[ADC_SIGNAL_CH_NUMBER] =
{
{ 3300000U, 1000000U, 0U, 0U,},
{ 3300000U, 1000000U, 0U, 0U,},
{ 0U, 0U, 0U, 0U,},
{ 0U, 0U, 670U, 300U,},
};
/* Private function prototypes ----------------------------------------------*/
......@@ -115,10 +111,11 @@ void Analog_Signal_Conv_Init(void)
}
}
RTE_ADC_Init(0,2);
RTE_ADC_Init(0,3);
RTE_ADC_Init(0,5);
RTE_ADC_Init(0,7);
for (i = 0U; i < ADC_CONV_CH_NUMBER; i++)
{
RTE_ADC_Init(0, u8ADCChList[i]);
}
for (i = 0U; i < ADC_SIGNAL_CH_NUMBER; i++)
{
......
......@@ -4,7 +4,7 @@
* \attention
*
* This file is automatically generated by analog signals configuration tool.
* Date : 2024/3/31 13:14:40
* Date : 2024/6/16 16:49:27
* Cfg Tool Ver : 1.1.0
* Engineer : ShiHao
* (c) Heilongjiang TYW electronics co., LTD
......@@ -33,8 +33,8 @@ enum ADCChName
};
/* Exported macro ------------------------------------------------------------*/
#define ADC_TOTAL_CH_NUMBER (4U)
#define ADC_SIGNAL_CH_NUMBER (4U)
#define ADC_TOTAL_CH_NUMBER (2U)
#define ADC_SIGNAL_CH_NUMBER (2U)
#define ADC_REF_VOLTAGE u16ADCRefVoltage
/* Exported variables --------------------------------------------------------*/
......
......@@ -4,8 +4,9 @@
#include "cgc.h"
#include "gpio.h"
#include "isr.h"
#include "Analog\Analog_Signals.h"
uint8_t u8NewChNum[4] = {2, 3, 7, 5};
// uint8_t u8NewChNum[4] = {2, 3, 7, 5};
void RTC_ADC_Interrupt(void *msg)
{
......@@ -17,6 +18,7 @@ void RTE_ADC_Init(const uint8_t u8ChList[], uint8_t u8ChNum)
{
GPIO_InitTypeDef GPIO_InitStructure = {0};
ADC_InitTypeDef ADC_InitStructure = {0};
if(u8ChNum<=7)
{
......@@ -133,13 +135,13 @@ void RTE_ADC_Get_Conversion_Result(uint16_t *pu16Data, uint8_t u8ChNum)
uint8_t i;
if ((pu16Data != 0U) && (u8ChNum > 0U) && (u8ChNum <= 4U))
if ((pu16Data != 0U) && (u8ChNum > 0U) && (u8ChNum <= ADC_TOTAL_CH_NUMBER))
{
if (RTE_ADC_Get_Conversion_Status() == 0U)
{
for (i = 0U; i < u8ChNum; i++)
{
ADC_Converse(u8NewChNum[i], 1, pu16Data);
ADC_Converse((ADC_Channel_t)u8ADCChList[i], 1, pu16Data);
pu16Data++;
}
}
......
......@@ -4,6 +4,8 @@
#include <stdint.h>
extern const uint8_t u8ADCChList[];
#define ADC_RESOLUTION (4096U) /* 12bit ADC */
extern void RTE_ADC_Init(const uint8_t u8ChList[], uint8_t u8ChNum);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment