IR Exported Functions
- group IR_Exported_Functions
Functions
-
void IR_DeInit(void)
Deinitializes the IR peripheral registers to their default values.
Example usage
void driver_ir_init(void) { IR_DeInit(); }
- 参数:
None. –
- 返回:
None.
-
void IR_Init(IR_InitTypeDef *IR_InitStruct)
Initializes the IR peripheral according to the specified parameters in IR_InitStruct.
Example usage
void driver_ir_init(void) { RCC_PeriphClockCmd(APBPeriph_IR, APBPeriph_IR_CLOCK, ENABLE); IR_InitTypeDef IR_InitStruct; IR_StructInit(&IR_InitStruct); IR_InitStruct.IR_Freq = 38000; IR_InitStruct.IR_Mode = IR_MODE_RX; IR_InitStruct.IR_RxStartMode = IR_RX_AUTO_MODE; IR_InitStruct.IR_RxFIFOThrLevel = IR_RX_FIFO_THR_LEVEL; IR_InitStruct.IR_RxFIFOFullCtrl = IR_RX_FIFO_FULL_DISCARD_NEWEST; IR_InitStruct.IR_RxFilterTime = IR_RX_FILTER_TIME_50ns; IR_InitStruct.IR_RxTriggerMode = IR_RX_FALL_EDGE; IR_InitStruct.IR_RxCntThrType = IR_RX_Count_High_Level; IR_InitStruct.IR_RxCntThr = 0x1F40; IR_Init(&IR_InitStruct); IR_Cmd(IR_MODE_RX, ENABLE); IR_ClearRxFIFO(); }
- 参数:
IR_InitStruct – [in] Pointer to a IR_InitTypeDef structure that contains the configuration information for the specified IR peripheral.
- 返回:
None.
-
void IR_StructInit(IR_InitTypeDef *IR_InitStruct)
Fills each IR_InitStruct member with its default value.
Example usage
void driver_ir_init(void) { RCC_PeriphClockCmd(APBPeriph_IR, APBPeriph_IR_CLOCK, ENABLE); IR_InitTypeDef IR_InitStruct; IR_StructInit(&IR_InitStruct); IR_InitStruct.IR_Freq = 38000; IR_InitStruct.IR_Mode = IR_MODE_RX; IR_InitStruct.IR_RxStartMode = IR_RX_AUTO_MODE; IR_InitStruct.IR_RxFIFOThrLevel = IR_RX_FIFO_THR_LEVEL; IR_InitStruct.IR_RxFIFOFullCtrl = IR_RX_FIFO_FULL_DISCARD_NEWEST; IR_InitStruct.IR_RxFilterTime = IR_RX_FILTER_TIME_50ns; IR_InitStruct.IR_RxTriggerMode = IR_RX_FALL_EDGE; IR_InitStruct.IR_RxCntThrType = IR_RX_Count_High_Level; IR_InitStruct.IR_RxCntThr = 0x1F40; IR_Init(&IR_InitStruct); IR_Cmd(IR_MODE_RX, ENABLE); IR_ClearRxFIFO(); }
- 参数:
IR_InitStruct – [in] Pointer to an IR_InitTypeDef structure which will be initialized.
- 返回:
None.
-
void IR_Cmd(uint32_t mode, FunctionalState NewState)
Enable or disable the selected IR mode.
Example usage
void driver_ir_init(void) { RCC_PeriphClockCmd(APBPeriph_IR, APBPeriph_IR_CLOCK, ENABLE); IR_InitTypeDef IR_InitStruct; IR_StructInit(&IR_InitStruct); IR_InitStruct.IR_Freq = 38000; IR_InitStruct.IR_Mode = IR_MODE_RX; IR_InitStruct.IR_RxStartMode = IR_RX_AUTO_MODE; IR_InitStruct.IR_RxFIFOThrLevel = IR_RX_FIFO_THR_LEVEL; IR_InitStruct.IR_RxFIFOFullCtrl = IR_RX_FIFO_FULL_DISCARD_NEWEST; IR_InitStruct.IR_RxFilterTime = IR_RX_FILTER_TIME_50ns; IR_InitStruct.IR_RxTriggerMode = IR_RX_FALL_EDGE; IR_InitStruct.IR_RxCntThrType = IR_RX_Count_High_Level; IR_InitStruct.IR_RxCntThr = 0x1F40; IR_Init(&IR_InitStruct); IR_Cmd(IR_MODE_RX, ENABLE); IR_ClearRxFIFO(); }
- 参数:
mode – [in] Selected IR operation mode. This parameter can be one of the following values:
IR_MODE_TX: Transmission mode.
IR_MODE_RX: Receiving mode.
NewState – [in] New state of the operation mode. This parameter can be: ENABLE or DISABLE.
- 返回:
None.
-
void IR_StartManualRxTrigger(void)
Start trigger receive, only in manual receive mode.
Example usage
void ir_demo(void) { IR_StartManualRxTrigger(); }
- 参数:
None. –
- 返回:
None.
-
void IR_SetRxCounterThreshold(uint32_t IR_RxCntThrType, uint32_t IR_RxCntThr)
Config counter threshold value in receiving mode.You can use it to stop receiving IR data.
Example usage
void ir_demo(void) { IR_SetRxCounterThreshold(IR_RX_Count_Low_Level, 0x100); }
- 参数:
IR_RxCntThrType – [in] Count threshold type. This parameter can be the following values:
IR_RX_Count_Low_Level: Low level counter value >= IR_RxCntThr, trigger IR_INT_RX_CNT_THR interrupt.
IR_RX_Count_High_Level: High level counter value >= IR_RxCntThr, trigger IR_INT_RX_CNT_THR interrupt.
IR_RxCntThr – [in] Configure IR Rx counter threshold value which can be 0 to 0x7fffffffUL.
- 返回:
None.
-
void IR_SendBuf(uint32_t *pBuf, uint32_t len, FunctionalState IsLastPacket)
Send data.
Example usage
void ir_demo(void) { uint32_t data_buf[80] = {0}; IR_SendBuf(data_buf, 68, DISABLE); }
- 参数:
pBuf – [in] Data buffer to send.
len – [in] Send data length.
IsLastPacket – [in] Is it the last package of data. This parameter can be one of the following values:
ENABLE: The last data in IR packet and there is no continous data.In other words, an infrared data transmission is completed.
DISABLE: There is data to be transmitted continuously.
- 返回:
None.
-
void IR_SendCompenBuf(IRTxCompen_TypeDef comp_type, uint32_t *pBuf, uint32_t len, FunctionalState IsLastPacket)
Send compensation data.
Example usage
void ir_demo(void) { uint32_t data_buf[80] = {0}; IR_SendCompenBuf(IR_COMPEN_FLAG_1_2_CARRIER, data_buf, 68, DISABLE); }
- 参数:
comp_type – [in] Compensation data type. This parameter can be one of the following values:
IR_COMPEN_FLAG_1_2_CARRIER: 1/2 carrier freqency.
IR_COMPEN_FLAG_1_4_CARRIER: 1/4 carrier freqency.
IR_COMPEN_FLAG_1_N_SYSTEM_CLK: MOD((0x48[27:16]+0x00[11:0]), 4095)/40MHz. User can call function of IR_ConfigCompParam to configure 0x48[27:16].
buf – [in] Data buffer to send.
length – [in] Data length.
IsLastPacket – [in] Is it the last package of data. This parameter can be the following values:
ENABLE: The last data in IR packet and there is no continous data.In other words, an infrared data transmission is completed.
DISABLE: There is data to be transmitted continuously.
- 返回:
None.
-
void IR_ReceiveBuf(uint32_t *pBuf, uint32_t length)
Read data From RX FIO.
Example usage
void ir_demo(void) { uint32_t data_buf[80] = {0}; IR_ReceiveBuf(data_buf, 68); }
- 参数:
pBuf – [in] Buffer address to receive data.
length – [in] Read data length.
- 返回:
None.
-
void IR_INTConfig(uint32_t IR_INT, FunctionalState NewState)
Enables or disables the specified IR interrupt source.
Example usage
void ir_demo(void) { IR_INTConfig(IR_INT_TF_EMPTY, ENABLE); }
- 参数:
IR_INT – [in] Specifies the IR interrupt source to be enabled or disabled. This parameter can be oen of the following values:
IR_INT_TF_EMPTY: TX FIFO empty interrupt source.
IR_INT_TF_LEVEL: TX FIFO threshold interrupt source.
IR_INT_TF_OF: TX FIFO overflow interrupt source.
IR_INT_RF_FULL: RX FIFO full interrupt source.
IR_INT_RF_LEVEL: RX FIFO threshold interrupt source.
IR_INT_RX_CNT_OF: RX counter overflow interrupt source.
IR_INT_RF_OF: RX FIFO overflow interrupt source.
IR_INT_RX_CNT_THR: RX counter threshold interrupt source.
IR_INT_RF_ERROR: RX FIFO error read interrupt source. Trigger when RX FIFO empty and read RX FIFO.
IR_INT_RISING_EDGE: IR RX Rising edge interrupt.
IR_INT_FALLING_EDGE: IR RX Falling edge interrupt.
NewState – [in] New state of the specified IR interrupt. This parameter can be: ENABLE or DISABLE.
- 返回:
None.
-
void IR_MaskINTConfig(uint32_t IR_INT, FunctionalState NewState)
Mask or unmask the specified IR interrupt source.
Example usage
void ir_demo(void) { IR_MaskINTConfig(IR_INT_TF_EMPTY, ENABLE); }
- 参数:
IR_INT – [in] Specifies the IR interrupts sources to be mask or unmask. This parameter can be the following values:
IR_INT_TF_EMPTY: TX FIFO empty interrupt.
IR_INT_TF_LEVEL: TX FIFO threshold interrupt.
IR_INT_TF_OF: TX FIFO overflow interrupt.
IR_INT_RF_FULL: RX FIFO full interrupt.
IR_INT_RF_LEVEL: RX FIFO threshold interrupt.
IR_INT_RX_CNT_OF: RX counter overflow interrupt.
IR_INT_RF_OF: RX FIFO overflow interrupt.
IR_INT_RX_CNT_THR: RX counter threshold interrupt.
IR_INT_RF_ERROR: RX FIFO error read interrupt. Trigger when RX FIFO empty and read RX FIFO.
IR_INT_RISING_EDGE: IR RX Rising edge interrupt.
IR_INT_FALLING_EDGE: IR RX Falling edge interrupt.
NewState – [in] New state of the specified IR interrupts. This parameter can be: ENABLE or DISABLE.
- 返回:
None.
-
ITStatus IR_GetINTStatus(uint32_t IR_INT)
Get the specified IR interrupt status.
Example usage
void ir_demo(void) { ITStatus int_status = IR_GetINTStatus(IR_INT_TF_EMPTY); }
- 参数:
IR_INT – [in] The specified IR interrupts. This parameter can be one of the following values:
IR_INT_TF_EMPTY: TX FIFO empty interrupt.
IR_INT_TF_LEVEL: TX FIFO threshold interrupt.
IR_INT_TF_OF: TX FIFO overflow interrupt.
IR_INT_RF_FULL: RX FIFO full interrupt.
IR_INT_RF_LEVEL: RX FIFO threshold interrupt.
IR_INT_RX_CNT_OF: RX counter overflow interrupt.
IR_INT_RF_OF: RX FIFO overflow interrupt.
IR_INT_RX_CNT_THR: RX counter threshold interrupt.
IR_INT_RF_ERROR: RX FIFO error read interrupt. Trigger when RX FIFO empty and read RX FIFO.
IR_INT_RISING_EDGE: IR RX Rising edge interrupt.
IR_INT_FALLING_EDGE: IR RX Falling edge interrupt.
- 返回:
The new state of IR_INT (SET or RESET).
-
void IR_ClearINTPendingBit(uint32_t IR_CLEAR_INT)
Clear the IR interrupt pending bit.
Example usage
void ir_demo(void) { IR_ClearINTPendingBit(IR_INT_RX_CNT_OF_CLR); }
- 参数:
IR_CLEAR_INT – [in] specifies the interrupt pending bit to clear. This parameter can be any combination of the following values:
IR_INT_TF_EMPTY_CLR: Clear TX FIFO empty interrupt.
IR_INT_TF_LEVEL_CLR: Clear TX FIFO threshold interrupt.
IR_INT_TF_OF_CLR: Clear TX FIFO overflow interrupt.
IR_INT_RF_FULL_CLR: Clear RX FIFO full interrupt.
IR_INT_RF_LEVEL_CLR: Clear RX FIFO threshold interrupt.
IR_INT_RX_CNT_OF_CLR: Clear RX counter overflow interrupt.
IR_INT_RF_OF_CLR: Clear RX FIFO overflow interrupt.
IR_INT_RX_CNT_THR_CLR: Clear RX counter threshold interrupt.
IR_INT_RF_ERROR_CLR: Clear RX FIFO error read interrupt. Trigger when RX FIFO empty and read RX FIFO.
IR_INT_RX_RISING_EDGE_CLR: Clear RX Rising edge interrupt.
IR_INT_RX_FALLING_EDGE_CLR: Clear RX Falling edge interrupt.
- 返回:
None.
-
uint16_t IR_GetTxFIFOFreeLen(void)
Get free size of TX FIFO.
Example usage
void ir_demo(void) { uint16_t data_len = IR_GetTxFIFOFreeLen(); }
- 参数:
None. –
- 返回:
The free size of TX FIFO.
-
uint16_t IR_GetRxDataLen(void)
Get data size in RX FIFO.
Example usage
void ir_demo(void) { uint16_t data_len = IR_GetRxDataLen(); }
- 参数:
None. –
- 返回:
Current data size in RX FIFO.
-
void IR_SendData(uint32_t data)
Send one data.
Example usage
void ir_demo(void) { IR_SendData(0x80000100); }
- 参数:
data – [in] Send data.
- 返回:
None.
-
uint32_t IR_ReceiveData(void)
Read one data.
Example usage
void ir_demo(void) { uint32_t data = IR_ReceiveData(); }
- 参数:
None. –
- 返回:
Data which read from RX FIFO.
-
void IR_SetTxThreshold(uint8_t thd)
Set tx threshold, when TX FIFO depth <= threshold value trigger interrupt.
Example usage
void ir_demo(void) { IR_SetTxThreshold(30); }
- 参数:
thd – [in] Tx threshold.
- 返回:
None.
-
void IR_SetRxThreshold(uint8_t thd)
Set tx threshold, when RX FIFO depth >= threshold value trigger interrupt.
Example usage
void ir_demo(void) { IR_SetRxThreshold(2); }
- 参数:
thd – [in] Rx threshold.
- 返回:
None.
-
uint32_t IR_GetRxCurrentCount(void)
Get IR RX current count.
Example usage
void ir_demo(void) { uint32_t count = IR_GetRxCurrentCount(); }
- 参数:
None. –
- 返回:
Current counter.
-
void IR_ClearTxFIFO(void)
Clear IR TX FIFO.
Example usage
void ir_demo(void) { IR_ClearTxFIFO(); }
- 参数:
None. –
- 返回:
None.
-
void IR_ClearRxFIFO(void)
Clear IR RX FIFO.
Example usage
void ir_demo(void) { IR_ClearRxFIFO(); }
- 参数:
None. –
- 返回:
None.
-
FlagStatus IR_GetFlagStatus(uint32_t IR_FLAG)
Check whether the specified IR flag is set.
Example usage
void ir_demo(void) { FlagStatus flag_status = IR_GetFlagStatus(IR_FLAG_TF_EMPTY); }
- 参数:
IR_FLAG – [in] Specifies the flag to check. This parameter can be one of the following values:
IR_FLAG_TF_EMPTY: TX FIFO empty or not. If SET, TX FIFO is empty.
IR_FLAG_TF_FULL: TX FIFO full or not. If SET, TX FIFO is full.
IR_FLAG_TX_RUN: TX run or not. If SET, TX is running.
IR_FLAG_RF_EMPTY: RX FIFO empty or not. If SET, RX FIFO is empty.
IR_FLAG_RF_FULL: RX FIFO full or not. If SET, RX FIFO is full.
IR_FLAG_RX_RUN: RX run or not. If SET, RX is running.
- 返回:
The new state of IR_FLAG (SET or RESET).
-
void IR_SetTxInverse(FunctionalState NewState)
Set or reset tx data inverse.
Example usage
void ir_demo(void) { IR_SetTxInverse(ENABLE); }
- 参数:
NewState – [in] This parameter can be: ENABLE or DISABLE.
- 返回:
None.
-
void IR_TxOutputInverse(FunctionalState NewState)
Enbale TX output inverse or not.
Example usage
void ir_demo(void) { IR_TxOutputInverse(ENABLE); }
- 参数:
NewState – [in] This parameter can be: ENABLE or DISABLE.
- 返回:
None.
-
uint32_t IR_GetRxCurrentLevel(void)
Get IR RX Level.
Example usage
void ir_demo(void) { uint32_t level = IR_GetRxCurrentLevel(); }
- 参数:
None. –
- 返回:
Current Level.
-
void IR_ClkConfig(IRSrcClock_TypeDef ClockSrc, IRSrcClockDiv_TypeDef ClockDiv)
IR clock config.
- 参数:
ClockSrc – [in] specifies the clock source to gates its clock.
ClockDiv – [in] specifies the clock divide to gates its clock.
ClockSrc – specifies the clock source to gates its clock.
ClockDiv – specifies the clock divide to gates its clock.
- 返回:
None
- 返回:
None
-
void IR_DeInit(void)