Commit 45c3d181 authored by 高士达's avatar 高士达

Merge branch 'CJL' into 'dev'

Cjl

See merge request !115
parents 9495c409 bb405dff
......@@ -136,7 +136,7 @@ const uint8_t user_opt_data[4] __attribute__((used)) __attribute__((section(".AR
// <0x72=> VLVDH = 4.06V/3.98V, VLVDL = 2.75V ( interrupt & reset mode )
// <i> Please setting the item for interrupt & reset mode
// </h>
0x72,
0x73,
/**
* @brief HOCO Control BYTE (FRQSEL)
......
......@@ -70,7 +70,7 @@ void Protocol_Service(void)
readNum = UARTRead_Cbk(mDataBufPtr + mDataBufLen, 256 - mDataBufLen);
if ( readNum > 0 )
{
mDataBufLen += readNum;
mDataBufLen += (Protocol_uint16_t)readNum;
// 解析协议
len = Protocol_Parse(mDataBufPtr, mDataBufLen);
if ( (len > 0) && (len < mDataBufLen) )
......@@ -187,7 +187,7 @@ Protocol_uint32_t Protocol_Parse(const Protocol_uint8_t *pData, Protocol_uint32_
d_printf("\n");
#endif
}
ProcData.DataLen = dataLen - 4;
ProcData.DataLen = (Protocol_uint8_t)(dataLen - 4);
memcpy(ProcData.Data, pData + 5, ProcData.DataLen);
ProtocolSetData_Cbk(&ProcData);
}
......
......@@ -275,7 +275,7 @@ void UART_Put(Protocol_uint16_t Data)
}
else
{
UARTRxBuf.Rx_Buffer [ UARTRxBuf.write_pos ] = Data;
UARTRxBuf.Rx_Buffer [ UARTRxBuf.write_pos ] = (Protocol_uint8_t)Data;
UARTRxBuf.write_pos = (UARTRxBuf.write_pos + 1) % UART_RX_MAX_DEPTH;
}
......
......@@ -4479,7 +4479,7 @@ void SEG_Scan_SET_Fuel_Coolant_Dial(uint8_t coolant)
uint8_t Espeed_check_SEG_step = 0;
void SEG_Scan_SET_EspeedDial(void)
{
uint16_t a = 0;
uint8_t a = 0;
a = (Espeed_check_SEG_step / 10) ;
SEG_SET_EspeedDial(1, a);
......
......@@ -12,33 +12,33 @@ typedef enum
GPIO_Control_DIG = 0, /*!< GPIO Control Digital */
GPIO_Control_ANA = 1, /*!< GPIO Control Analogy */
}GPIOControl_TypeDef;
#define IS_GPIO_Control(Ctrl) (((Ctrl) == GPIO_Control_ANA) || ((Ctrl) == GPIO_Control_DIG) )? 1:0
#define IS_GPIO_Control(Ctrl) (((Ctrl) == GPIO_Control_ANA) || ((Ctrl) == GPIO_Control_DIG) )
typedef enum
{
GPIO_Mode_OUT = 0, /*!< GPIO Output Mode */
GPIO_Mode_IN = 1, /*!< GPIO Input Mode */
}GPIOMode_TypeDef;
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) )? 1:0
#define IS_GPIO_MODE(MODE) (((MODE) == GPIO_Mode_IN) || ((MODE) == GPIO_Mode_OUT) )
typedef enum
{
GPIO_OType_PP = 0,//普通输?
GPIO_OType_OD = 1 //开漏输?
GPIO_OType_PP = 0,//普通输
GPIO_OType_OD = 1 //开漏输
}GPIOOType_TypeDef;
#define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))? 1:0
#define IS_GPIO_OTYPE(OTYPE) (((OTYPE) == GPIO_OType_PP) || ((OTYPE) == GPIO_OType_OD))
typedef enum
{
GPIO_PuPd_NOPULL = 0x00,
GPIO_PuPd_UP = 0x01,
GPIO_PuPd_UP = 0x01,
GPIO_PuPd_DOWN = 0x02
}GPIOPuPd_TypeDef;
#define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_NOPULL) || ((PUPD) == GPIO_PuPd_UP) || \
((PUPD) == GPIO_PuPd_DOWN))? 1:0
((PUPD) == GPIO_PuPd_DOWN))
typedef enum
{
GPIO_Level_LOW = 0x00,
GPIO_Level_HIGH = 0x01,
GPIO_Level_HIGH = 0x01
}GPIOInit_Level;
typedef enum
......@@ -58,7 +58,7 @@ typedef enum
#endif
GPIO_PORT12 = 0x0C,
GPIO_PORT13 = 0x0D,
GPIO_PORT14 = 0x0E,
GPIO_PORT14 = 0x0E
}GPIO_Port_t;
#ifdef BAT32G1XX_80PIN
......@@ -97,7 +97,7 @@ typedef enum
#define GPIO_Pin_7 ((uint16_t)0x0080) /* Pin 7 selected */
#define GPIO_PIN_MASK ((uint16_t)0x00FF) /* PIN mask for assert test */
#define IS_GPIO_PIN(PIN) (((PIN) & GPIO_PIN_MASK ) != (uint16_t)0x00) ? 1:0
#define IS_GPIO_PIN(PIN) ((((PIN) & ~GPIO_PIN_MASK ) == (uint16_t)0x00) && ((PIN) != (uint16_t)0x00))
#define IS_GET_GPIO_PIN(PIN) (((PIN) == GPIO_Pin_0) || \
((PIN) == GPIO_Pin_1) || \
......@@ -106,7 +106,7 @@ typedef enum
((PIN) == GPIO_Pin_4) || \
((PIN) == GPIO_Pin_5) || \
((PIN) == GPIO_Pin_6) || \
((PIN) == GPIO_Pin_7))? 1:0
((PIN) == GPIO_Pin_7))
typedef enum
......@@ -176,8 +176,8 @@ typedef enum
GROUP_AF_SDA10 ,
#endif
GROUP_AF_TAIO , //定时器A外部事件输入和脉冲输?
GROUP_AF_TAO , //定时器A的脉冲输?
GROUP_AF_TAIO , //定时器A外部事件输入和脉冲输
GROUP_AF_TAO , //定时器A的脉冲输
GROUP_AF_VCOUT0,
GROUP_AF_VCOUT1,
......@@ -190,9 +190,10 @@ typedef enum
GROUP_AF_TMIOB0,
GROUP_AF_CRXD ,
GROUP_AF_CTXD ,
GROUP_AF_CTXD ,
GROUP_AF_END
}GROUP_AF_t;
#define IS_GPIO_AF(GPIO_AF) ((GPIO_AF) < GROUP_AF_CTXD || ((GPIO_AF) == GROUP_AF_CTXD))
#define IS_GPIO_AF(GPIO_AF) (GPIO_AF < GROUP_AF_END)
......@@ -283,7 +284,7 @@ typedef enum
GPIO_P152 ,
GPIO_P153 ,
#endif
GPIO_PIN_END ,
GPIO_PIN_END
}GPIO_Source_t;
typedef enum
......@@ -292,7 +293,7 @@ typedef enum
GPIO_PIOR2 =0,
GPIO_PIOR0 =2,
GPIO_PIOR1 =4,
GPIO_PIOR3 =7,
GPIO_PIOR3 =7
}GPIO_PIOR_t;
typedef enum
......@@ -305,8 +306,8 @@ typedef enum
PIOR_BIT5,
PIOR_BIT6,
PIOR_BIT7,
PIOR_CBIT10, //组合bit位(bit1 bit0?
PIOR_CBIT67, //组合bit位(bit6 bit7?
PIOR_CBIT10, //组合bit位(bit1 bit0
PIOR_CBIT67 //组合bit位(bit6 bit7)
}PIOR_BIT_t;
typedef struct
......@@ -355,6 +356,6 @@ void GPIO_ResetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin);
void GPIO_ToggleBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin);
void GPIO_Init(GPIO_Port_t PORTx,GPIO_InitTypeDef* GPIO_InitStruct);
int GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_Source_Grp, GROUP_AF_t GPIO_AF);
uint8_t GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_Source_Grp, GROUP_AF_t GPIO_AF);
#endif
......@@ -122,7 +122,7 @@
#define UART1_PHASE_POS ((uint16_t)((1 << 2) & UART_PHASE_MASK))
#define UART2_PHASE_POS ((uint16_t)((1 << 0) & UART_PHASE_MASK))
#define UART_CTRL_POS ((uint16_t)0x01)
#define UART_CTRL_POS ((uint8_t)0x01)
/** @defgroup UART_Flags
* @{
......
......@@ -122,35 +122,41 @@ uint16_t ADC_Converse_Scan(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
volatile uint8_t flag;
uint32_t total = 0;
assert_param(IS_SCAN_START_CHAN(ch));
if(times == 0)
{
return 0;
}
else{
assert_param(IS_SCAN_START_CHAN(ch));
INTC_DisableIRQ(ADC_IRQn); // disable INTAD interrupt
INTC_DisableIRQ(ADC_IRQn); // disable INTAD interrupt
ADC->ADM0 &= ~ADC_Enable;
ADC->ADM0 &= ~ADC_Enable;
ADC->ADM1 |= 0x08; //enable one-shot convertion
ADC->ADM1 |= 0x80; //set sacn mode
ADC->ADM1 |= 0x08; //enable one-shot convertion
ADC->ADM1 |= 0x80; //set sacn mode
ADC->ADTRG = ADC_ExternalTrig_Software;
ADC->ADM0 |= ADC_Enable;
ADC->ADTRG = ADC_ExternalTrig_Software;
ADC->ADM0 |= ADC_Enable;
ADC->ADS = ch;
ADC->ADS = ch;
for(i=0; i<times;i++)
{
ADC->ADM0 |= ADC_Start_Cmp; //adc start
for (j=0; j<4; j++)
for(i=0; i<times;i++)
{
while(INTC_GetPendingIRQ(ADC_IRQn) == 0);
INTC_ClearPendingIRQ(ADC_IRQn); // clear INTAD interrupt flag
ADC->ADM0 |= ADC_Start_Cmp; //adc start
for (j=0; j<4; j++)
{
while(INTC_GetPendingIRQ(ADC_IRQn) == 0);
INTC_ClearPendingIRQ(ADC_IRQn); // clear INTAD interrupt flag
*buf++ = ADC->ADCR;
total += ADC->ADCR;
*buf++ = ADC->ADCR;
total += ADC->ADCR;
}
}
return (uint16_t)(total / times); // return average value
}
}
return (total / times); // return average value
}
/**
......@@ -192,7 +198,7 @@ uint16_t ADC_Converse(ADC_Channel_t ch, uint32_t times, uint16_t *buf)
*buf++ = ADC->ADCR;
total += ADC->ADCR;
}
return (total / times); // return average value
return (uint16_t)(total / times); // return average value
}
}
......
......@@ -522,7 +522,7 @@ uint8_t CAN_ABTModeTransmitConfig(CAN_Type* CANx, uint16_t DBT)
}
/* Set ABT time delay for each block transmit */
CANx->CGMABTD = DBT;
CANx->CGMABTD = (uint8_t)DBT;
/* Set ABTTRG to start trigger ABT mode */
CANx->CGMABT = CAN_GMABT_START_ABTTRG;
......@@ -913,7 +913,10 @@ void CAN_Receive_IT(CAN_Type* CANx, CANBuffList_t *listbuf)
CANMSG_Type *CANxMSGy;
CanTxRxMsg canMsgRec;
canMsgRec.CacheType = 0;
canMsgRec.Interrupt = 0;
canMsgRec.OverWriteConfig = 0;
canMsgRec.RTR = 0;
/* Check the parameters */
assert_param(IS_CAN_ALL_PERIPH(CANx));
......
......@@ -60,11 +60,11 @@ void CGC_PER1PeriphClockCmd(uint32_t CGC_PER1Periph, FunctionalState NewState)
if (NewState != DISABLE)
{
CGC->PER1 |= CGC_PER1Periph;
CGC->PER1 |= (uint8_t)CGC_PER1Periph;
}
else
{
CGC->PER1 &= ~CGC_PER1Periph;
CGC->PER1 &= (uint8_t)(~CGC_PER1Periph);
}
}
......@@ -95,11 +95,11 @@ void CGC_PER2PeriphClockCmd(uint32_t CGC_PER2Periph, FunctionalState NewState)
if (NewState != DISABLE)
{
CGC->PER2 |= CGC_PER2Periph;
CGC->PER2 |= (uint8_t)CGC_PER2Periph;
}
else
{
CGC->PER2 &= ~CGC_PER2Periph;
CGC->PER2 &= (uint8_t)(~CGC_PER2Periph);
}
}
/**
......
......@@ -34,11 +34,11 @@ void DAC_Start(DAC_Channel_t ch)
{
if(ch & 0x01)
{
DAC->DAM |= DAC_DAM_DACE0_Msk; /* enables D/A conversion operation */
DAC->DAM |= (uint8_t)DAC_DAM_DACE0_Msk; /* enables D/A conversion operation */
}
if(ch & 0x02)
{
DAC->DAM |= DAC_DAM_DACE1_Msk; /* enables D/A conversion operation */
DAC->DAM |= (uint8_t)DAC_DAM_DACE1_Msk; /* enables D/A conversion operation */
}
}
/***********************************************************************************************************************
......@@ -51,11 +51,11 @@ void DAC_Stop(DAC_Channel_t ch)
{
if(ch & 0x01)
{
DAC->DAM &= ~DAC_DAM_DACE0_Msk; /* stops D/A conversion operation */
DAC->DAM &= (uint8_t)(~DAC_DAM_DACE0_Msk); /* stops D/A conversion operation */
}
if(ch & 0x02)
{
DAC->DAM &= ~DAC_DAM_DACE1_Msk; /* stops D/A conversion operation */
DAC->DAM &= (uint8_t)(~DAC_DAM_DACE1_Msk); /* stops D/A conversion operation */
}
}
......@@ -85,5 +85,5 @@ void DAC_Set_Value(DAC_Channel_t ch, uint8_t regvalue)
***********************************************************************************************************************/
void DAC_Set_PowerOff(void)
{
CGC->PER1 &= ~CGC_PER1_DACEN_Msk; /* stops input clock supply */
CGC->PER1 &= (uint8_t)(~CGC_PER1_DACEN_Msk); /* stops input clock supply */
}
......@@ -53,5 +53,5 @@ void m0_delay_us(uint32_t volatile number_of_us)
***********************************************************************************************************************/
void delay_init(uint32_t sysclk)
{
Value_us = sysclk/1000000;
Value_us = (uint8_t)(sysclk/1000000);
}
......@@ -19,13 +19,13 @@ void DMA_Init(DMA_InitTypeDef * DMA_InitStruct)
}
if(DMA_InitStruct->DMA_ChainTrans == 0)
{
DMAVEC->VEC[DMA_InitStruct->DMA_Vector] = DMA_InitStruct->DMA_CtrlId;
DMAVEC->VEC[DMA_InitStruct->DMA_Vector] = (uint8_t)(DMA_InitStruct->DMA_CtrlId);
}
else
{
if(DMA_InitStruct->DMA_ChainTrans == DMA_ChainTrans_Head)
{
DMAVEC->VEC[DMA_InitStruct->DMA_Vector] = DMA_InitStruct->DMA_CtrlId;
DMAVEC->VEC[DMA_InitStruct->DMA_Vector] = (uint8_t)(DMA_InitStruct->DMA_CtrlId);
}
}
DMAVEC->CTRL[DMA_InitStruct->DMA_CtrlId].DMACR = DMA_InitStruct->DMA_DataSize | (DMA_InitStruct->DMA_RepeatInt << 5) \
......
......@@ -20,7 +20,7 @@ void ELC_Start(uint32_t event_src, uint32_t event_dst)
sfr_addr = &ELC->ELSELR00;
// ELSELRn(n=00~14) = Link Destination Number
*(sfr_addr + event_src) = event_dst;
*(sfr_addr + event_src) = (uint8_t)(event_dst);
}
/***********************************************************************************************************************
......
......@@ -207,7 +207,7 @@ FLASH_STATUS flash_write(uint32_t adr, uint32_t sz, uint8_t *buf)
cross = 0;
}
ptr_base = (uint8_t *)(adr & ~(SECTOR_SIZE-1)); /* get sector base address: Each sector is 512 bytes (i.e. 128 words) */
offset = adr & (SECTOR_SIZE-1); /* get offset */
offset = (uint16_t)(adr & (SECTOR_SIZE-1)); /* get offset */
/* Save the Flash data temporarily */
if(cross)
......
......@@ -19,7 +19,7 @@ void assert_failed(uint8_t* file, uint32_t line)
#if defined(BAT32G1XX_64PIN) || defined(BAT32G1XX_80PIN)
GPIO_PIN_AF_TABLE_t funcAfTab[] =
const GPIO_PIN_AF_TABLE_t funcAfTab[] =
{
{GROUP_AF_INTP1, {{GPIO_PIOR0,PIOR_BIT0,GPIO_P52}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}}},
{GROUP_AF_INTP2, {{GPIO_PIOR0,PIOR_BIT0,GPIO_P53}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}}},
......@@ -62,7 +62,7 @@ GPIO_PIN_AF_TABLE_t funcAfTab[] =
{GROUP_AF_ODEFAULT,{{PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}}},
};
#elif defined BAT32G1XX_48PIN
GPIO_PIN_AF_TABLE_t funcAfTab[] =
const GPIO_PIN_AF_TABLE_t funcAfTab[] =
{
{GROUP_AF_INTP8, {{PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {GPIO_PIOR0,PIOR_BIT7,GPIO_P00}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}}},
{GROUP_AF_RXD1, {{GPIO_PIOR0,PIOR_BIT5,GPIO_P73}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}, {PIOR_NONE,PIOR_BIT0,GPIO_DEF}}},
......@@ -166,7 +166,7 @@ void GPIO_Set_Value(__IO uint8_t *port, uint8_t value)
uint8_t GPIO_Get_Value(__IO uint8_t *port)
{
// PORT->PMS = 0x01; /*!< Digital output level of the pin is read */
return (*port); /*!< PL = value */
return (*(port - 0x260)); /*!< PL = value */
}
/**
......@@ -175,8 +175,9 @@ uint8_t GPIO_Get_Value(__IO uint8_t *port)
* @param port, such as P0, P1, P2...
* @param pinMsk
* e.g., bit0: 0x01, bit1: 0x02, bit0~3: 0x0F, bit0~7: 0xFF
* @retval ERROR or NO_ERROR .
*/
int GPIO_PinCheck(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
static uint8_t GPIO_PinCheck(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
{
if(PORTx == GPIO_PORT0)
{
......@@ -235,41 +236,41 @@ void GPIO_Init(GPIO_Port_t PORTx,GPIO_InitTypeDef* GPIO_InitStruct)
if(GPIO_InitStruct->GPIO_Level == GPIO_Level_HIGH)
{
*((volatile uint8_t*)(&PORT->P0 + PORTx))|= (1<<currentpin);
*((volatile uint8_t*)(&PORT->P0 + (uint8_t)PORTx)) |= (1<<currentpin);
}
else
{
*((volatile uint8_t*)(&PORT->P0 + PORTx))&= ~(1<<currentpin);
*((volatile uint8_t*)(&PORT->P0 + (uint8_t)PORTx)) &= ~(uint8_t)(1<<currentpin);
}
if(GPIO_InitStruct->GPIO_Ctrl == GPIO_Control_DIG ) /*digitial input/output*/
{
*((volatile uint8_t*)(&PORT->PMC0 +PORTx)) &= ~((!GPIO_InitStruct->GPIO_Ctrl) << currentpin);
*((volatile uint8_t*)(&PORT->PMC0 +(uint8_t)PORTx)) &= ~(uint8_t)((!(GPIO_InitStruct->GPIO_Ctrl)) << currentpin);
if(GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT)
{
*((volatile uint8_t*)(&PORT->PM0 +PORTx)) &= ~((!GPIO_InitStruct->GPIO_Mode) << currentpin);
*((volatile uint8_t*)(&PORT->PM0 +(uint8_t)PORTx)) &= ~(uint8_t)(!(GPIO_InitStruct->GPIO_Mode) << currentpin);
assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->GPIO_OType));
if(GPIO_InitStruct->GPIO_OType == GPIO_OType_PP)
{
*((volatile uint8_t*)(&PORT->POM0 +PORTx)) &= ~((!GPIO_InitStruct->GPIO_OType) << currentpin);
*((volatile uint8_t*)(&PORT->POM0 +(uint8_t)PORTx)) &= ~(uint8_t)((!GPIO_InitStruct->GPIO_OType) << currentpin);
}
else
{
*((volatile uint8_t*)(&PORT->POM0 +PORTx)) |= GPIO_InitStruct->GPIO_OType << currentpin;
*((volatile uint8_t*)(&PORT->POM0 +(uint8_t)PORTx)) |= (uint8_t)(GPIO_InitStruct->GPIO_OType << currentpin);
}
}
else
{
*((volatile uint8_t*)(&PORT->PM0 +PORTx)) |= (GPIO_InitStruct->GPIO_Mode << currentpin);
*((volatile uint8_t*)(&PORT->PM0 +(uint8_t)PORTx)) |= (uint8_t)(GPIO_InitStruct->GPIO_Mode << currentpin);
}
}
else /*analogy input*/
{
*((volatile uint8_t*)(&PORT->PMC0 +PORTx)) |= GPIO_InitStruct->GPIO_Ctrl << currentpin;
*((volatile uint8_t*)(&PORT->PMC0 +(uint8_t)PORTx)) |= (uint8_t)(GPIO_InitStruct->GPIO_Ctrl << currentpin);
}
assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
if(GPIO_InitStruct->GPIO_PuPd == GPIO_PuPd_UP)
{
*((volatile uint8_t*)(&PORT->PU0 +PORTx)) |= (1<<currentpin);
*((volatile uint8_t*)(&PORT->PU0 +(uint8_t)PORTx)) |= (uint8_t)(1<<currentpin);
}
else if(GPIO_InitStruct->GPIO_PuPd == GPIO_PuPd_DOWN)
{
......@@ -297,7 +298,7 @@ void GPIO_SetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param(IS_GPIO_ALL_PERIPH(PORTx));
assert_param(IS_GPIO_PIN(GPIO_Pin));
*((volatile uint8_t*)(&PORT->P0 +PORTx))|= GPIO_Pin;
*((volatile uint8_t*)(&PORT->PSET0 +(uint8_t)PORTx)) = GPIO_Pin;
}
......@@ -316,7 +317,7 @@ void GPIO_ResetBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param(IS_GPIO_ALL_PERIPH(PORTx));
assert_param(IS_GPIO_PIN(GPIO_Pin));
*((volatile uint8_t*)(&PORT->P0 +PORTx)) &= ~GPIO_Pin;
*((volatile uint8_t*)(&PORT->PCLR0 +(uint8_t)PORTx)) = GPIO_Pin;
}
/**
......@@ -334,7 +335,7 @@ void GPIO_ToggleBits(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param(IS_GPIO_ALL_PERIPH(PORTx));
assert_param(IS_GPIO_PIN(GPIO_Pin));
*((volatile uint8_t*)(&PORT->P0 +PORTx)) ^= GPIO_Pin;
*((volatile uint8_t*)(&PORT->P0 +(uint8_t)PORTx)) ^= GPIO_Pin;
}
/**
* @brief Reads the specified input port pin.
......@@ -351,7 +352,7 @@ uint8_t GPIO_ReadInputDataBit(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param(IS_GPIO_ALL_PERIPH(PORTx));
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
if(((*((volatile uint8_t*)(&PORT->P0 +PORTx))) & GPIO_Pin) != Bit_RESET)
if(((*((volatile uint8_t*)(&PORT->PREAD0 +(uint8_t)PORTx))) & GPIO_Pin) != (uint8_t)Bit_RESET)
{
bitstatus = (uint8_t)Bit_SET;
}
......@@ -379,7 +380,7 @@ uint8_t GPIO_ReadOutputDataBit(GPIO_Port_t PORTx, uint16_t GPIO_Pin)
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
if(((*((volatile uint8_t*)(&PORT->P0 +PORTx))) & GPIO_Pin) != Bit_RESET)
if(((*((volatile uint8_t*)(&PORT->P0 +(uint8_t)PORTx))) & GPIO_Pin) != (uint8_t)Bit_RESET)
{
bitstatus = (uint8_t)Bit_SET;
}
......@@ -396,23 +397,42 @@ void GPIO_SetPIOR(uint16_t idx,GPIO_Source_t GPIO_Source_Grp)
{
uint8_t i;
for(i=0;i<PIOR_MAX_NUM;i++)
for(i=0;i< sizeof(funcAfTab[idx].piorInfo)/sizeof(PIOR_INFO_t); i++)
{
if(funcAfTab[idx].piorInfo[i].pior != PIOR_NONE)
{
if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT10)
{
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<0);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<1);
}
else if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT67)
{
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<6);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<7);
}
else
{
//Clear PIOR bit
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~ (1<<funcAfTab[idx].piorInfo[i].bitIndex);
}
}
if(GPIO_Source_Grp == funcAfTab[idx].piorInfo[i].bitHigPin)
{
if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT10) //只针对pior1 的pior11 pior10组合bit
if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT10)
{
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + funcAfTab[idx].piorInfo[i].pior)) |= (1<<0);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + funcAfTab[idx].piorInfo[i].pior)) |= (1<<1);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) |= (1<<0);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) |= (1<<1);
}
else if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT67) //只针对pior3 的bit6 bit7组合bit
else if(funcAfTab[idx].piorInfo[i].bitIndex == PIOR_CBIT67)
{
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + funcAfTab[idx].piorInfo[i].pior)) |= (1<<6);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<7);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) |= (1<<6);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) &= ~(1<<7);
}
else
{
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + funcAfTab[idx].piorInfo[i].pior)) |= (1<<funcAfTab[idx].piorInfo[i].bitIndex);
*((volatile uint8_t*)(GPIO_PIOR_CFG_BASE + (uint8_t)funcAfTab[idx].piorInfo[i].pior)) |= (1<<(uint8_t)funcAfTab[idx].piorInfo[i].bitIndex);
}
break;
}
......@@ -424,11 +444,11 @@ void GPIO_SetPIOR(uint16_t idx,GPIO_Source_t GPIO_Source_Grp)
* @param PORTx: where x can be (0..14) to select the GPIO peripheral for BAT32G137 devices
* @param GPIO_Pin: specifies the port bits to be written.
* This parameter can be any combination of GPIO_Pin_x where x can be (0..7).
* @param GPIO_Source_Grp: specifies the port bits and port,such as P70P51......
* @param GPIO_Source_Grp: specifies the port bits and port,such as P70��P51......
* @param GPIO_AF: digital functions which can be mapped to any chip pin
* @retval error or success .
*/
int GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_Source_Grp, GROUP_AF_t GPIO_AF)
uint8_t GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_Source_Grp, GROUP_AF_t GPIO_AF)
{
uint16_t id = 0;
/* Check the parameters */
......@@ -441,7 +461,7 @@ int GPIO_PinAFConfig(GPIO_Port_t PORTx, uint16_t GPIO_Pin, GPIO_Source_t GPIO_So
return GPIO_ERR;
}
for(id =0;funcAfTab[id].func !=0;id++)
for(id =0; id < sizeof(funcAfTab)/sizeof(GPIO_PIN_AF_TABLE_t);id++)
{
if(funcAfTab[id].func == GPIO_AF)
{
......
......@@ -664,37 +664,37 @@ uint8_t I2C_Get_TransmitMode(SCIAFSelect_TypeDef I2Cx)
case I2C00:
{
I2C0_TypeDef *I2C_Instance = &SCI0->I2C0;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case I2C01:
{
I2C1_TypeDef *I2C_Instance = &SCI0->I2C1;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case I2C10:
{
I2C2_TypeDef *I2C_Instance = &SCI0->I2C2;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case I2C11:
{
I2C3_TypeDef *I2C_Instance = &SCI0->I2C3;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case I2C20:
{
I2C4_TypeDef *I2C_Instance = &SCI1->I2C4;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case I2C21:
{
I2C5_TypeDef *I2C_Instance = &SCI1->I2C5;
Mode = I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(I2C_TransmitMode_Mask & ((I2C_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
#if defined(BAT32G1XX_80PIN) || defined(BAT32G1XX_100PIN)
......
......@@ -77,8 +77,8 @@ void I2CA_DeInit(I2CASelect_TypeDef I2CAx)
static void IICA_Init(IICA_TypeDef *IICA_Instance, I2CA_InitTypeDef* I2CA_InitStruct)
{
uint8_t tmpreg = 0;
uint8_t tmp_wl, tmp_wh;
uint32_t fmck;
uint8_t tmp_wl = 0, tmp_wh = 0;
uint32_t fmck = 0;
tmpreg = IICA_Instance->IICCTL1;
/* I2CA register setting for control register n1 */
......@@ -752,13 +752,13 @@ I2CA_Status I2CA_Slave_TransmitData(I2CASelect_TypeDef I2CAx,uint8_t *Reg, uint8
else
{
/* When the address match is success */
if ((Address_Match < 2) && I2CA_GetFlagStaus(I2CAx,I2CA_STATUS_COI)) //接收地址和自身从机地址一致
if ((Address_Match < 2) && I2CA_GetFlagStaus(I2CAx,I2CA_STATUS_COI)) //���յ�ַ�������ӻ���ַһ��
{
Address_Match ++;
if (Address_Match == 1)
{
I2CA_Instance->SVA|= 0x01; //第一次先读
I2CA_Instance->SVA|= 0x01; //��һ���ȶ�
}
else if (Address_Match == 2)
{
......@@ -775,7 +775,7 @@ I2CA_Status I2CA_Slave_TransmitData(I2CASelect_TypeDef I2CAx,uint8_t *Reg, uint8
/* Sending or receiving */
if (I2CA_GetFlagStaus(I2CAx,I2CA_STATUS_TRC)) //send status
{
I2CA_SET_REG(I2CAx,IICCTL00,I2CA_WTIM_BIT);//在输入9个时钟,将时钟置为低电
I2CA_SET_REG(I2CAx,IICCTL00,I2CA_WTIM_BIT);//������9��ʱ�ӣ���ʱ����Ϊ�͵�ƽ
I2CA_WriteByte(I2CAx,*Data);
Data++;
Send_Length++;
......
......@@ -24,19 +24,19 @@ void INTP_Init(INTP_InitTypeDef* Intp_InitStruct)
}
if(Intp_InitStruct->INTP_Select < INTP8)
{
INTM->EGN0 &= ~Intp_InitStruct->INTP_Select;
INTM->EGP0 &= ~Intp_InitStruct->INTP_Select;
INTM->EGN0 &= (uint8_t)(~Intp_InitStruct->INTP_Select);
INTM->EGP0 &= (uint8_t)(~Intp_InitStruct->INTP_Select);
INTM->EGN0 |= ((Intp_InitStruct->EXTI_Trigger & 0x01U) >> 0) << currentpin;
INTM->EGP0 |= ((Intp_InitStruct->EXTI_Trigger & 0x02U) >> 1) << currentpin;
INTM->EGN0 |= (uint8_t)(((Intp_InitStruct->EXTI_Trigger & 0x01U) >> 0) << currentpin);
INTM->EGP0 |= (uint8_t)(((Intp_InitStruct->EXTI_Trigger & 0x02U) >> 1) << currentpin);
}
else
{
INTM->EGN1 &= ~Intp_InitStruct->INTP_Select;
INTM->EGP1 &= ~Intp_InitStruct->INTP_Select;
INTM->EGN1 &= (uint8_t)(~Intp_InitStruct->INTP_Select);
INTM->EGP1 &= (uint8_t)(~Intp_InitStruct->INTP_Select);
INTM->EGN1 |= ((Intp_InitStruct->EXTI_Trigger & 0x01U) >> 0) << (currentpin-8);
INTM->EGP1 |= ((Intp_InitStruct->EXTI_Trigger & 0x02U) >> 1) << (currentpin-8);
INTM->EGN1 |= (uint8_t)(((Intp_InitStruct->EXTI_Trigger & 0x01U) >> 0) << (currentpin-8));
INTM->EGP1 |= (uint8_t)(((Intp_InitStruct->EXTI_Trigger & 0x02U) >> 1) << (currentpin-8));
}
for (w_count = 0U; w_count <= KEY_WAITTIME; w_count++)
......
......@@ -505,37 +505,37 @@ uint8_t SSPI_Get_TransmitMode(SCIAFSelect_TypeDef SSPIx)
case SSPI00:
{
I2C0_TypeDef *SSPI_Instance = &SCI0->I2C0;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case SSPI01:
{
I2C1_TypeDef *SSPI_Instance = &SCI0->I2C1;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case SSPI10:
{
I2C2_TypeDef *SSPI_Instance = &SCI0->I2C2;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case SSPI11:
{
I2C3_TypeDef *SSPI_Instance = &SCI0->I2C3;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case SSPI20:
{
I2C4_TypeDef *SSPI_Instance = &SCI1->I2C4;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
case SSPI21:
{
I2C5_TypeDef *SSPI_Instance = &SCI1->I2C5;
Mode = SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14);
Mode = (uint8_t)(SSPI_TransmitMode_Mask & ((SSPI_Instance->SCR & SCI_RECEPTION_TRANSMISSION) >> 14));
}
break;
#if defined(BAT32G1XX_80PIN) || defined(BAT32G1XX_100PIN)
......@@ -575,37 +575,37 @@ uint8_t SSPI_Get_MasterMode(SCIAFSelect_TypeDef SSPIx)
case SSPI00:
{
I2C0_TypeDef *SSPI_Instance = &SCI0->I2C0;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
case SSPI01:
{
I2C1_TypeDef *SSPI_Instance = &SCI0->I2C1;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
case SSPI10:
{
I2C2_TypeDef *SSPI_Instance = &SCI0->I2C2;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
case SSPI11:
{
I2C3_TypeDef *SSPI_Instance = &SCI0->I2C3;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
case SSPI20:
{
I2C4_TypeDef *SSPI_Instance = &SCI1->I2C4;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
case SSPI21:
{
I2C5_TypeDef *SSPI_Instance = &SCI1->I2C5;
Mode = ((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
Mode = (uint8_t)((SSPI_Instance->SMR & (SPI_Mode_Slave<<14)) >> 14);
}
break;
#if defined(BAT32G1XX_80PIN) || defined(BAT32G1XX_100PIN)
......
......@@ -190,7 +190,7 @@ void TIM_Cmd(TIMSelect_TypeDef TIMx,uint8_t Chx,TIM_FunState NewState)
* @brief Set the specified TIMER channel's count num.
* @param TIMx: where x can be 0, 1, select TIEMR peripheral.
* @param Chx: where x can be 0, 1,2,3 select channel of specified TIMER peripheral.
* @arg TTM_Channel_0、TTM_Channel_1、TTM_Channel_2、TTM_Channel_3
* @arg TTM_Channel_0��TTM_Channel_1��TTM_Channel_2��TTM_Channel_3
* @param counter: the count num of the TIEMR channel.
* @retval None
*/
......@@ -278,7 +278,7 @@ int TIM_Init(TIM_InitTypeDef *TIM_InitStruct)
for(masterPos = 0; masterPos < 8; masterPos++)
{
posm = ((char)0x01) << masterPos;
masterNum = TIM_InitStruct->TIM_Selection_Master & posm;
masterNum = (uint8_t)(TIM_InitStruct->TIM_Selection_Master & posm);
if(masterNum == posm)
{
currentMChan[j]=masterPos;
......@@ -294,11 +294,11 @@ int TIM_Init(TIM_InitTypeDef *TIM_InitStruct)
*TIM_reg.TDR[currentMChan[j]] = TIM_InitStruct->TIM_Period[currentMChan[j]] -1;
*TIM_reg.TO &= ~(1 << masterPos);
*TIM_reg.TOE &= ~(1 << masterPos);
MISC->NFEN1 |= (1<<currentMChan[j]); //后加
MISC->NFEN1 |= (1<<currentMChan[j]); //���
j++;
}
}
for(chanPos = 0; chanPos < 8; chanPos++) //从属通道配置
for(chanPos = 0; chanPos < TIMER_CHAN_MAX_NUM; chanPos++) //����ͨ������
{
pos = ((uint8_t)0x01) << chanPos;
chanNum = TIM_InitStruct->TIM_Channel & pos;
......
......@@ -217,12 +217,12 @@ void TMM_Init(TMM_InitTypeDef *TMM_InitStruct)
if(TMM_InitStruct->TMM_Mode == TMM_Mode_CompPWM)
{
CGC_PER1PeriphClockCmd(CGC_PER1Periph_PWMCUTOFF,ENABLE);
*TMM_reg.TMMR |= _80_TMM_TMGRD1_BUFFER |_40_TMM_TMGRC1_BUFFER|_20_TMM_TMGRD0_BUFFER; //the TMGRD1 used as TMGRB1 buffer registerTMGRC1 used as TMGRA1 buffer register TMGRD0 are used TMGRB0 buffer register
*TMM_reg.TMMR |= _80_TMM_TMGRD1_BUFFER |_40_TMM_TMGRC1_BUFFER|_20_TMM_TMGRD0_BUFFER; //the TMGRD1 used as TMGRB1 buffer register��TMGRC1 used as TMGRA1 buffer register�� TMGRD0 are used TMGRB0 buffer register
*TMM_reg.TMCR[TMM_InitStruct->TMM_Select] = TMM_InitStruct->TMM_CounterClear | TMM_InitStruct->TMM_Clk; //counter cleared condition
*TMM_reg.TMFCR |= (TMM_InitStruct->TMM_BDTR.TMM_NegativeState << 3) | (TMM_InitStruct->TMM_BDTR.TMM_PostiveState << 2)| TMM_InitStruct->TMM_Combine_TransMode;
*TMM_reg.TMDF[TMM_InitStruct->TMM_Select] |= (TMM_InitStruct->TMM_BDTR.TMIOA_BreakPolarity << 6) |(TMM_InitStruct->TMM_BDTR.TMIOB_BreakPolarity << 4) \
| (TMM_InitStruct->TMM_BDTR.TMIOC_BreakPolarity << 2) |(TMM_InitStruct->TMM_BDTR.TMIOD_BreakPolarity << 0);
*TMM_reg.TMDF[TMM_InitStruct->TMM_Select] |= (uint8_t)((TMM_InitStruct->TMM_BDTR.TMIOA_BreakPolarity << 6) |(TMM_InitStruct->TMM_BDTR.TMIOB_BreakPolarity << 4) \
| (TMM_InitStruct->TMM_BDTR.TMIOC_BreakPolarity << 2) |(TMM_InitStruct->TMM_BDTR.TMIOD_BreakPolarity << 0));
TMM->TMELC |= (TMM_InitStruct->TMM_BDTR.TMM_Break <<1) << (TMM_InitStruct->TMM_Select << 4);
......
......@@ -95,7 +95,7 @@ uint8_t TimerM_PWM_counter_Output_Init(TIMERM_PWM_Counter_en_t counter, uint16_t
return 1;
}
TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;//这里需要计算,调试�? period; //周期设置为period
TIMM_InitStructure[counter].TMM_CHA_Pulse = (uint16_t)(cycle_pulse[counter] & 0x0FFFF);//这里需要计算,调试�? period; //周期设置为period
......@@ -201,7 +201,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
switch (ch)
{
case TIMERM_CHB:
TIMM_InitStructure[counter].TMM_CHB_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRB. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_CHB_Pulse = (uint16_t)(((cycle_pulse[counter]) ) & 0x0FFFF); //TM计数达到TMGRB. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHB.TMM_PWMInitLevel = TMM_PWMInitLevel_High;
TIMM_InitStructure[counter].TMM_PWM.TMM_CHB.TMM_PWMActiveLevel = ActiveLevel;
if (counter == TIMERM_COUNTER0)
......@@ -217,7 +217,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
break;
case TIMERM_CHC:
TIMM_InitStructure[counter].TMM_CHC_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRC. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_CHC_Pulse = (uint16_t)(((cycle_pulse[counter]) ) & 0x0FFFF); //TM计数达到TMGRC. 占空�?:duty2/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHC.TMM_PWMInitLevel = TMM_PWMInitLevel_High;
TIMM_InitStructure[counter].TMM_PWM.TMM_CHC.TMM_PWMActiveLevel = ActiveLevel;
if (counter == TIMERM_COUNTER0)
......@@ -232,7 +232,7 @@ uint8_t TimerM_PWM_CH_Output_init(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Ch
break;
case TIMERM_CHD:
TIMM_InitStructure[counter].TMM_CHD_Pulse = ((cycle_pulse[counter]) ) & 0x0FFFF; //TM计数达到TMGRD. 占空�?:duty3/period
TIMM_InitStructure[counter].TMM_CHD_Pulse = (uint16_t)(((cycle_pulse[counter]) ) & 0x0FFFF); //TM计数达到TMGRD. 占空�?:duty3/period
TIMM_InitStructure[counter].TMM_PWM.TMM_CHD.TMM_PWMInitLevel = TMM_PWMInitLevel_High;//TMM_PWMInitLevel_High;//
TIMM_InitStructure[counter].TMM_PWM.TMM_CHD.TMM_PWMActiveLevel = ActiveLevel;//TMM_PWMActiveLevel_Low;//TMM_PWMActiveLevel_High;//
if (counter == TIMERM_COUNTER0)
......@@ -304,12 +304,12 @@ uint8_t TimerM_PWM_set_duty(TIMERM_PWM_Counter_en_t counter, TIMERM_PWM_Channel_
if (counter == TIMERM_COUNTER0)
{
high_level_Pulse[counter][ch] = (((cycle_pulse[counter] * duty) / 1000) & 0x0FFFF);
TMM0_Set_Counter(1 << (ch + 1), high_level_Pulse[counter][ch]);
TMM0_Set_Counter(1 << (ch + 1), (uint16_t)(high_level_Pulse[counter][ch]));
}
else if (counter == TIMERM_COUNTER1)
{
high_level_Pulse[counter][ch] = (((cycle_pulse[counter] * duty) / 1000) & 0x0FFFF);
TMM1_Set_Counter(1 << (ch + 1), high_level_Pulse[counter][ch]);
TMM1_Set_Counter(1 << (ch + 1), (uint16_t)(high_level_Pulse[counter][ch]));
}
else
{
......@@ -365,12 +365,12 @@ uint8_t TimerM_PWM_set_freq(TIMERM_PWM_Counter_en_t counter, uint16_t freq )
high_level_Pulse[counter][TIMERM_CHC] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHC]) / 1000) & 0x0FFFF);
high_level_Pulse[counter][TIMERM_CHD] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHD]) / 1000) & 0x0FFFF);
TIMM_InitStructure[counter].TMM_CHB_Pulse = high_level_Pulse[counter][TIMERM_CHB];
TIMM_InitStructure[counter].TMM_CHC_Pulse = high_level_Pulse[counter][TIMERM_CHC];
TIMM_InitStructure[counter].TMM_CHD_Pulse = high_level_Pulse[counter][TIMERM_CHD];
TIMM_InitStructure[counter].TMM_CHB_Pulse = (uint16_t)(high_level_Pulse[counter][TIMERM_CHB]);
TIMM_InitStructure[counter].TMM_CHC_Pulse = (uint16_t)(high_level_Pulse[counter][TIMERM_CHC]);
TIMM_InitStructure[counter].TMM_CHD_Pulse = (uint16_t)(high_level_Pulse[counter][TIMERM_CHD]);
TIMM_InitStructure[counter].TMM_CHA_Pulse = cycle_pulse[counter] & 0x0FFFF;
TIMM_InitStructure[counter].TMM_CHA_Pulse = (uint16_t)(cycle_pulse[counter] & 0x0FFFF);
TMM_Init(&TIMM_InitStructure[counter]);
......@@ -394,10 +394,10 @@ uint8_t TimerM_PWM_set_freq2(TIMERM_PWM_Counter_en_t counter, uint16_t freq )
high_level_Pulse[counter][TIMERM_CHB] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHB]) / 1000) & 0x0FFFF);
high_level_Pulse[counter][TIMERM_CHC] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHC]) / 1000) & 0x0FFFF);
high_level_Pulse[counter][TIMERM_CHD] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHD]) / 1000) & 0x0FFFF);
TMM0_Set_Counter(1 << 1, high_level_Pulse[counter][TIMERM_CHB]);
TMM0_Set_Counter(1 << 2, high_level_Pulse[counter][TIMERM_CHC]);
TMM0_Set_Counter(1 << 3, high_level_Pulse[counter][TIMERM_CHD]);
TMM0_Set_Counter(1, cycle_pulse[counter]);
TMM0_Set_Counter(1 << 1, (uint16_t)(high_level_Pulse[counter][TIMERM_CHB]));
TMM0_Set_Counter(1 << 2, (uint16_t)(high_level_Pulse[counter][TIMERM_CHC]));
TMM0_Set_Counter(1 << 3, (uint16_t)(high_level_Pulse[counter][TIMERM_CHD]));
TMM0_Set_Counter(1, (uint16_t)(cycle_pulse[counter]));
}
else if (counter == TIMERM_COUNTER1)
{
......@@ -405,10 +405,10 @@ uint8_t TimerM_PWM_set_freq2(TIMERM_PWM_Counter_en_t counter, uint16_t freq )
high_level_Pulse[counter][TIMERM_CHB] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHB]) / 1000) & 0x0FFFF);
high_level_Pulse[counter][TIMERM_CHC] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHC]) / 1000) & 0x0FFFF);
high_level_Pulse[counter][TIMERM_CHD] = (((cycle_pulse[counter] * pwm_duty[counter][TIMERM_CHD]) / 1000) & 0x0FFFF);
TMM1_Set_Counter(1 << 1, high_level_Pulse[counter][TIMERM_CHB]);
TMM1_Set_Counter(1 << 2, high_level_Pulse[counter][TIMERM_CHC]);
TMM1_Set_Counter(1 << 3, high_level_Pulse[counter][TIMERM_CHD]);
TMM1_Set_Counter(1, cycle_pulse[counter]);
TMM1_Set_Counter(1 << 1, (uint16_t)(high_level_Pulse[counter][TIMERM_CHB]));
TMM1_Set_Counter(1 << 2, (uint16_t)(high_level_Pulse[counter][TIMERM_CHC]));
TMM1_Set_Counter(1 << 3, (uint16_t)(high_level_Pulse[counter][TIMERM_CHD]));
TMM1_Set_Counter(1, (uint16_t)(cycle_pulse[counter]));
}
else
{
......
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