Ejemplo n.º 1
0
/*******************************************************************************
* 初始化函数
********************************************************************************/
void init()
{
    CyGlobalIntEnable; //全局中断开启
    
    ADC_DelSig_1_Start();  /* 配置并开启ADC */
    ADC_DelSig_1_StartConvert(); /* 开始进行转换 */
    
    Uart_Rx_ISR_StartEx(RxInterruptHandler);      /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */
    Uart_Tx_ISR_StartEx(TxInterruptHandler);      /* 开启 Uart Tx 并连接到 TxInterruptHandler */
    UART_Start();     /* 开启 UART */
    
    Uart_Rx_ISR_1_StartEx(Rx_1_InterruptHandler);      /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */
    Uart_Tx_ISR_1_StartEx(Tx_1_InterruptHandler);      /* 开启 Uart Tx 并连接到 TxInterruptHandler */
    UART_1_Start();     /* 开启 UART1 */
    
    Uart_Rx_ISR_2_StartEx(Rx_1_InterruptHandler);      /* 开启 Uart Rx 中断 并连接到 RxInterruptHandler */
    Uart_Tx_ISR_2_StartEx(Tx_1_InterruptHandler);      /* 开启 Uart Tx 并连接到 TxInterruptHandler */
    UART_2_Start();     /* 开启 UART2 */
    
    
    Timer_ISR_StartEx(TimerInterruptHandler); /* 开启 Timer 中断并连接到 TimerInterruptHandler */
    Timer_Start();          /* 开启定时器 */
    
    LCD_Char_1_Start(); /* 初始化并清除LCD */
    //LCD_Char_1_PrintString("init");
}
Ejemplo n.º 2
0
int main()
{
    uint16 Diff, FPS;
   
    CyGlobalIntEnable; /* Enable global interrupts. */

    PixelMask = 0;
    PixelCounter = 0;
    NoSpeed = 0;
    
    Timer_Start();
    Timer_ISR_StartEx(Timer_ISR);
    
    StripLights_Start();

    StripLights_Dim(0);
    StripLights_MemClear(0x00000000);
    StripLights_Trigger(1);

//    EZI2C_EzI2CSetBuffer1(sizeof(I2C_Struct.I2C_Buffer), sizeof(I2C_Struct.I2C_Buffer), I2C_Struct.I2C_Buffer);
//    EZI2C_Start();
    
    Diff = 60;
    
    for(;;)
    {
        //any Hall captures yet?
        if(Timer_Capture_Flag)
        {
            if(Timer_Capture > Timer_Capture_Last)
                Diff = Timer_Capture - Timer_Capture_Last;
            else
                Diff = (65535 - Timer_Capture_Last) + Timer_Capture;
            
            Timer_Capture_Flag = 0;
            StepColors();
            NoSpeed = 0;
        }
        //nope, maybe I stopped
        else
        {
            Timeout++;
        }
        //kill the lights if I'm standing still
        if(Timeout > 20000)
        {
            NoSpeed = 1;
            Timeout = 0;
        }
        
        FPS = FPS_SCALE/Diff;   //not using this but it could be fun later
        
//        I2C_Struct.I2C_Buffer[0] = (uint8)(Diff >>8);
//        I2C_Struct.I2C_Buffer[1] = (uint8)Diff;
//        I2C_Struct.I2C_Buffer[2] = (uint8)(FPS >>8);
//        I2C_Struct.I2C_Buffer[3] = (uint8)FPS;
//        if (!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_BUSY))
//        {
//            I2C_Struct.Capture = Diff;
//        }

        //OK, time to write out to the LEDs
        if(1 == NoSpeed)
            StripLights_MemClear(0x00000000);
        StripLights_Trigger(1);
        while(!StripLights_Ready());
    }
}