31volatile uint8_t IR_State = 0;
32volatile uint8_t IR_LDC_Ready = 0;
33volatile uint8_t IR_CTC_Ready = 0;
34volatile uint8_t IR_CTC0 = 0;
35volatile uint8_t IR_CTC1 = 0;
36volatile uint8_t IR_DAC = 0;
37volatile uint8_t IR_DAB = 0;
38volatile uint8_t IR_cnt = 0;
39volatile uint8_t IR_CODE[4] = {0x00, 0x00, 0x00, 0x00};
57 else if(IR_State == 1)
60 if((u32Time >= IR_LDC_MIN) && (u32Time <= IR_LDC_MAX))
73 else if((IR_State >= 2 && IR_State < 10) && (IR_LDC_Ready == 1))
76 IR_CTC0 = IR_CTC0 >> 1;
77 if((u32Time >= IR_BIT_0_MIN) && (u32Time <= IR_BIT_0_MAX))
79 else if((u32Time >= IR_BIT_1_MIN) && (u32Time <= IR_BIT_1_MAX))
85 else if((IR_State >= 10 && IR_State < 18) && (IR_LDC_Ready == 1))
88 IR_CTC1 = IR_CTC1 >> 1;
89 if((u32Time >= IR_BIT_0_MIN) && (u32Time <= IR_BIT_0_MAX))
91 else if((u32Time >= IR_BIT_1_MIN) && (u32Time <= IR_BIT_1_MAX))
97 else if((IR_State >= 18 && IR_State < 26) && (IR_LDC_Ready == 1))
100 IR_DAC = IR_DAC >> 1;
101 if((u32Time >= IR_BIT_0_MIN) && (u32Time <= IR_BIT_0_MAX))
103 else if((u32Time >= IR_BIT_1_MIN) && (u32Time <= IR_BIT_1_MAX))
110 else if((IR_State >= 26 && IR_State < 34) && (IR_LDC_Ready == 1))
113 IR_DAB = IR_DAB >> 1;
114 if((u32Time >= IR_BIT_0_MIN) && (u32Time <= IR_BIT_0_MAX))
116 else if((u32Time >= IR_BIT_1_MIN) && (u32Time <= IR_BIT_1_MAX))
123 if((IR_DAC ^ IR_DAB) == 0xff)
126 IR_CODE[0] = IR_CTC0;
127 IR_CODE[1] = IR_CTC1;
131 g_pfnIrDA_Code_Exe(IR_CODE);
132 printf(
"IR_cnt=%d, CTC0=%02x, CTC1=%02x, DAC=%02x, DAB=%02x\n", IR_cnt, IR_CTC0, IR_CTC1, IR_DAC, IR_DAB);
139#define NEC_LDC_MARK 16
140#define NEC_LDC_SPACE 8
141#define NEC_BIT_MARK 1
142#define NEC_ONE_SPACE 3
143#define NEC_ZERO_SPACE 1
184 for (nbyte=0; nbyte <
NEC_BYTES; nbyte++)
186 for (nbit=0; nbit < 8; nbit++)
189 if (data[nbyte] & (1 << nbit))
208 g_pfnIrDA_Code_Exe = pfnIrDA_Code_Exe;
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
#define PWM_CTL_CH2MOD_Msk
#define PWM_CTL_CH3MOD_Msk
#define PWM_CAPCTL_CAPRELOADFEN3_Msk
NuEdu-Basic01 IrDA NEC driver header file.
#define CLK_CLKSEL2_PWM1_CH23_S_HIRC
void CLK_EnableModuleClock(uint32_t u32ModuleIdx)
This function enable module clock.
int32_t CLK_SysTickDelay(uint32_t us)
This function execute delay function.
void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv)
This function set selected module clock source and module clock divider.
#define PWM1
Pointer to PWM1 register structure.
#define SYS
Pointer to SYS register structure.
#define PWM_FALLING_LATCH_INT_ENABLE
void PWM_EnableCapture(PWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM capture of selected channels.
#define PWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider)
This macro set the divider of the selected channel.
#define PWM_SET_CMR(pwm, u32ChannelNum, u32CMR)
This macro set the duty of the selected channel.
#define PWM_SET_CNR(pwm, u32ChannelNum, u32CNR)
This macro set the period of the selected channel.
void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function disables PWM output generation of selected channels.
#define PWM_SET_PRESCALER(pwm, u32ChannelNum, u32Prescaler)
This macro set the prescaler of the selected channel.
void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask)
This function start PWM module.
void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask)
This function enables PWM output generation of selected channels.
void PWM_EnableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
This function enable capture interrupt of selected channel.
#define SYS_PC_H_MFP_PC15_MFP_PWM1_CH2
#define SYS_PC_H_MFP_PC14_MFP_PWM1_CH3
void IrDa_NEC_Rx(uint32_t u32Time)
This function is used to detect NEC IR procotol.
void IrDA_NEC_TxRx_Init(IrDA_Code_Exe pfnIrDA_Code_Exe)
This function is used to initiate PWM for IrDA NEC.
void SendNEC(uint8_t *data)
This function is used to transmit IrDA NEC waveform through PC 15 (PWM1_CH3)
void SPACE(uint8_t N)
This function is used to transmit SPACE waveform.
void(* IrDA_Code_Exe)(volatile uint8_t *IR_CODE)
void Mark(uint8_t N)
This function is used to transmit MASK waveform Pulse = 1/3 duty @38KHz frequency.