void Set_LED_Pattern(uint8_t no, uint16_t delay, uint8_t bri){ xprintf(INFO "no=%d,delay=%d,bri=%d",no,delay,bri);FFL_(); if(no==9 || no==10){ PREV_LED_PATTERN = LED_PATTERN; LED_PATTERN = no; }else{ LED_PATTERN = no; } if(delay!=0){ MILLI_DELAY = delay; TIM_UpdateMatchValue(LPC_TIM2, 0, MILLI_DELAY); TIM_ResetCounter(LPC_TIM2); } else{ xprintf(INFO "LED delay not changed");FFL_(); } if(bri!=0) SetBrightness(bri); else{ xprintf(INFO "Brightness not changed");FFL_(); } // TIM_Cmd(LPC_TIM2,DISABLE); // xprintf(INFO "pattern=%d DELAY=%d Bri=%d",no,MILLI_DELAY,bri);FFL_(); resetLeds(); LED_Loop=0; LED_Loop_v1=0; LED_Loop_v2=0; LED_Loop_v3=0; TIM_Cmd(LPC_TIM0,ENABLE); TIM_Cmd(LPC_TIM2,ENABLE); }
/*********************************************************************//** * @brief TIMER1 interrupt handler * @param None * @return None ***********************************************************************/ void TIMER1_IRQHandler(void) { //duty cycle = 25% TIM_Cmd(LPC_TIM1,DISABLE); TIM_ClearIntPending(LPC_TIM1, TIM_MR0_INT); TIM_ResetCounter(LPC_TIM1); if((PWM1_State == ENABLE)) { TIM_UpdateMatchValue(LPC_TIM1,0, 200); PWM1_State = DISABLE; } else { TIM_UpdateMatchValue(LPC_TIM1,0, 600); PWM1_State = ENABLE; } TIM_Cmd(LPC_TIM1,ENABLE); }
/*********************************************************************//** * @brief TIMER0 interrupt handler * @param None * @return None ***********************************************************************/ void TIMER0_IRQHandler(void) { //duty cycle = 12.5% TIM_Cmd(LPC_TIM0,DISABLE); TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); TIM_ResetCounter(LPC_TIM0); if((PWM0_State == ENABLE)) { TIM_UpdateMatchValue(LPC_TIM0, 0, 100); PWM0_State = DISABLE; } else { TIM_UpdateMatchValue(LPC_TIM0, 0, 700); PWM0_State = ENABLE; } TIM_Cmd(LPC_TIM0,ENABLE); }
/*********************************************************************//** * @brief TIMER2 interrupt handler * @param None * @return None ***********************************************************************/ void TIMER2_IRQHandler(void) { //duty cycle = 37,5% TIM_Cmd(LPC_TIM2,DISABLE); TIM_ClearIntPending(LPC_TIM2, TIM_MR0_INT); TIM_ResetCounter(LPC_TIM2); if((PWM2_State == ENABLE)) { TIM_UpdateMatchValue(LPC_TIM2,0, 300); PWM2_State = DISABLE; } else { TIM_UpdateMatchValue(LPC_TIM2,0, 500); PWM2_State = ENABLE; } TIM_Cmd(LPC_TIM2,ENABLE); }
/*********************************************************************//** * @brief TIM3 interrupt handler sub-routine * @param None * @return None **********************************************************************/ void TIMER3_IRQHandler(void) { if (TIM_GetIntStatus(LPC_TIM3, TIM_MR0_INT)== SET) { TIM_Cmd(LPC_TIM3,DISABLE); // Disable Timer TIM_ResetCounter(LPC_TIM3); if(toggle_tim3 == TRUE) { TIM_UpdateMatchValue(LPC_TIM3,0,T1*10);//MAT3.0 toggle_tim3=FALSE; } else { TIM_UpdateMatchValue(LPC_TIM3,0,T2*10); toggle_tim3=TRUE; } TIM_Cmd(LPC_TIM3,ENABLE); // Start Timer } TIM_ClearIntPending(LPC_TIM3, TIM_MR0_INT); // clear Interrupt }
void tim_setmatch(int dev, uint8_t chan, uint32_t val) { TIM_UpdateMatchValue(tim_devs[dev], chan, val); }
void TIMER0_IRQHandler(void){ // xprintf("TIMER0_IRQ"); if (TIM_GetIntStatus(LPC_TIM0,TIM_MR0_INT)){ TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); #if 0 if(TOG[0]) // FIO_SetValue(LED_LE_PORT, LED_LE_BIT); GPIO_SetValue(LED_4_PORT, LED_4_BIT); else // FIO_ClearValue(LED_LE_PORT, LED_LE_BIT); GPIO_ClearValue(LED_4_PORT, LED_4_BIT); TOG[0]=!TOG[0]; // TIM_ClearIntPending(LPC_TIM0, TIM_MR0_INT); // return; #endif // xprintf(INFO "RIT N=%d B=%x NXT_T=%d TX=%x\n",SENDSEQ,SEND_BIT,DELAY_TIME,LED_PRECALC[0][SEND_BIT]); //Setup new timing for next Timer DELAY_TIME=SEQ_TIME[SENDSEQ]; SEND_BIT=SEQ_BIT[SENDSEQ]; //Retart sequence if required SENDSEQ++; SENDSEQ>=no_SEQ_BITS ? SENDSEQ=0 : 0; #ifdef DMA // xprintf("SEND_BIT:%d\n",SEND_BIT); // xprintf("DELAY_TIME:%d\n",DELAY_TIME); GPDMACfg.DMALLI = (uint32_t) &LinkerList[0][SEND_BIT][BufferNo]; GPDMA_Setup(&GPDMACfg); GPDMA_ChannelCmd(0, ENABLE); #endif TIM_UpdateMatchValue(LPC_TIM0,0,DELAY_TIME); FIO_SetValue(LED_OE_PORT, LED_OE_BIT); #ifdef RxDMA GPDMA_ChannelCmd(1, ENABLE); uint8_t reg; for(reg=6; 0<reg;reg--){ xprintf("%d ",reg-1); #if 0 if(BUFFER==1) SSP_SendData(LED_SPI_CHN, LED_PRECALC1[reg][SEND_BIT]); else SSP_SendData(LED_SPI_CHN, LED_PRECALC2[reg][SEND_BIT]); #endif //WaitForSend();//Wait if TX buffer full //while(LED_SPI_CHN->SR & SSP_STAT_BUSY); while(SSP_GetStatus(LED_SPI_CHN, SSP_STAT_BUSY)){ }; SSP_SendData(LED_SPI_CHN, LED_PRECALC[reg-1][SEND_BIT]); xprintf("%4x ",(LED_PRECALC[reg-1][SEND_BIT])); } for(reg=12; reg>6;reg--){ xprintf("%d ",reg-1); #if 0 if(BUFFER==1) SSP_SendData(LED_SPI_CHN, LED_PRECALC1[reg][SEND_BIT]); else SSP_SendData(LED_SPI_CHN, LED_PRECALC2[reg][SEND_BIT]); #endif //WaitForSend();//Wait if TX buffer full while(SSP_GetStatus(LED_SPI_CHN, SSP_STAT_BUSY)){ } SSP_SendData(LED_SPI_CHN, LED_PRECALC[reg-1][SEND_BIT]); // if (reg==7){ xprintf("%4x ",(LED_PRECALC[reg-1][SEND_BIT])); // } } LatchIn(); #endif /* UPDATE_COUNT+=1; ATE_COUNT=0; LED_UPDATE_REQUIRED=1; }*/ } }