|
void IRsend_sendGREE(long datavalue ,unsigned int greeCRC) { long data = 0; long temp = 0; IRsend_enableIROut(38); IRsend_mark(GREE_HDR_MARK); IRsend_space(GREE_HDR_SPACE); data = (datavalue&0xffffff80)|0x0A; for (int i = 0; i < 32; i++){ if (data & TOPBIT) { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ONE_SPACE); } else { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ZERO_SPACE); } data <<= 1; } data = 0x02; for (int i = 0; i < 3; i++){ if (data & TOPBIT) { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ONE_SPACE); } else { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ZERO_SPACE); } data <<= 1; } IRsend_mark(GREE_COM_MARK); IRsend_space(GREE_COM_SPACE); temp = datavalue&0x00000040;//7 data = (temp>>6); data = data<<4; temp = datavalue&0x00000020;//6 data = data|(temp>>5); data = data<<5; temp = datavalue&0x00000018;//5 4 data = data|(temp>>3); data = ((data<<16)|0x1000)<<1;//3 temp = datavalue&0x00000004; data = data|(temp>>2); data = (data<<5)|(greeCRC&0x000f); for (int i = 0; i < 32; i++){ if (data & TOPBIT) { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ONE_SPACE); } else { IRsend_mark(GREE_BIT_MARK); IRsend_space(GREE_ZERO_SPACE); } data <<= 1; } IRsend_mark(GREE_BIT_MARK); IRsend_space(0); } |
void Sct_Pwm_Init(uint32_t PWM_RATE) { /* Initialize the SCT as PWM and set frequency */ Chip_SCTPWM_Init(LPC_SCT); Chip_SCTPWM_SetRate(LPC_SCT, PWM_RATE); /* Setup Board specific output pin */ Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 9, IOCON_FUNC2 | IOCON_MODE_INACT | IOCON_DIGITAL_EN | IOCON_INPFILT_OFF); /* Use SCT0_OUT1 pin */ Chip_SCTPWM_SetOutPin(LPC_SCT, SCT_PWM_OUT, SCT_PWM_PIN_OUT); /* Start with 0% duty cycle */ Chip_SCTPWM_SetDutyCycle(LPC_SCT, SCT_PWM_OUT, Chip_SCTPWM_GetTicksPerCycle(LPC_SCT) / 4); //Chip_SCTPWM_Start(LPC_SCT); } |
void IRsend_mark(int time) { // Sends an IR IRsend_mark for the specified number of microseconds. // The IRsend_mark output is modulated at the PWM frequency. TIMER_ENABLE_PWM(); // Enable pin 3 PWM output if (time > 0) delayMicros(time); } /* Leave pin off for time (given in microseconds) */ void IRsend_space(int time) { // Sends an IR IRsend_space for the specified number of microseconds. // A IRsend_space is no output, so the PWM output is disabled. TIMER_DISABLE_PWM(); // Disable pin 3 PWM output if (time > 0) delayMicros(time); } |