Esempio n. 1
0
int main()
{
    char c;    
    int note=0; // current Notes
    int printFlag=0; // if set to 0 it prints the notes when they change
 
    CyGlobalIntEnable; /* Enable global interrupts. */
    CySysTickStart();
    
    Music_Start(0);
 
    UART_Start();
   
    sprintf(buff,"Started\n");
    UART_UartPutString(buff);

    for(;;)
    {
        c = UART_UartGetChar();
        switch(c)
        {
            case 's':
                UART_UartPutString("Start\n");
                Music_PlaySong(0);
            break;
            case 'S':
                UART_UartPutString("Stop\n");
                Music_Stop();
            break;
            case 'p':
                printFlag=0;
                break;
            case 'P':
                printFlag = 1;
            break;
            case 't': // put it back to the default
                Music_SetBPM(0);
            break;
            case 'T':
                Music_SetBPM(60);
            break;
                
            case '1':
                Music_PlaySong(0);
            break;
            case '2':
                Music_PlaySong(1);
            break;
        }
        
        if(note != Music_GetNote() && printFlag)
        {
            note = Music_GetNote();
            sprintf(buff,"Note = %d\n",note);
            UART_UartPutString(buff);
        }
    }
}
Esempio n. 2
0
// This is the main start function
// It sets up the systick callback and initializes everything to OFF
void `$INSTANCE_NAME`_Start(int callBackNumber)
{
    int row,col;
    for(row = 0;row<`$INSTANCE_NAME`_NUMROWS;row ++)
    {
        `$INSTANCE_NAME`_ledRows[row] = 0; // turn all columns off
        for(col = 0 ;  col < `$INSTANCE_NAME`_NUMCOLS; col ++ )
        {
            `$INSTANCE_NAME`_ledStates[row][col] = OFF;
        }
    }
    CySysTickStart();
    CySysTickSetCallback(callBackNumber,`$INSTANCE_NAME`_RunStateMachine);
}
Esempio n. 3
0
int main(){
    
    CySysTickStart();
    
    /* Configuramos el Reload del Systick */
    CySysTickSetReload(SYSTICK_RELOAD);
    
    /* Asignamos posiciones a las funciones */
    CySysTickSetCallback(0, LED);
    CySysTickSetCallback(1, LED_B);
    
    CySysTickClear();
    
    CyGlobalIntEnable;

    for(;;){
    }
}
Esempio n. 4
0
/*----------------------------------------------------------------------------
   Main: Initialize and start Kernel
*---------------------------------------------------------------------------*/
int main()
{	
    mtx_SerialDebug     = xSemaphoreCreateMutex();  /* Initialize the Debug Mutex           */

    /* Drivers                              */
    UART_Driver_Debug_Init();               /* Initialize serial debug                  */
    GPIO_Driver_Init();                     /* Initialize GPIO                          */
    CySysTickStart();
    /* ISR                                  */
    CyGlobalIntEnable;                      /* Init the interrupts                      */
    
    /* Operating System                     */
    osInit();                               /* Initialize all thread related tasks      */
    prvHardwareSetup();                     /* FreeRTOS setup                           */
	vTaskStartScheduler();                  /* Start the scheduler                      */
    
	return 1;
}
Esempio n. 5
0
int main()
{
    char c;    
    int note=0; // current note
    int printFlag=0; // if set to 0 it prints the notes when they change
 
    CyGlobalIntEnable;
    CySysTickStart();
    Music_Start(0);
    UART_Start();
    UART_UartPutString("Started\n");

    Music_AddSong(1,&scale);
    
    for(;;)
    {
        c = UART_UartGetChar();
        switch(c)
        {
            #ifdef Music_TWOCHANNELS
            case 'b': Music_BuzzOn(300,0);    break; // turn on the buzzer 1
            case 'B': Music_BuzzOff();        break; // turn off the buzzer 1
            case 'n': Music_BuzzOn(200,500);  break; // turn on the buzzer for 500ms
            #endif
            case 'p': printFlag=0;            break; // turn off the note printer
            case 'P': printFlag = 1;          break; // turn on the note printer
            case 't': Music_SetBPM(0);        break; // Put the song back to the default
            case 'T': Music_SetBPM(60);       break; // Put the current song to 60BPM
            case '1': Music_PlaySong(0,0);    break; // Play the 1st Song
            case '2': Music_PlaySong(1,0);    break; // Play the 2nd Song
            case 's':
                UART_UartPutString("Stop\n");
                Music_Stop();
            break;
        }
        
        if(note != Music_GetNote() && printFlag)
        {
            note = Music_GetNote();
            sprintf(buff,"Note = %d\n",note);
            UART_UartPutString(buff);
        }
    }
}
Esempio n. 6
0
/*******************************************************************************
* Function Name: int  main( void )
********************************************************************************/
int main(void)
{
    uint32  i;
    
    CyGlobalIntEnable; /* Enable global interrupts. */

    EZI2C_Start();
    #ifdef ENABLE_TUNER
    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),(uint8 *)&CapSense_dsRam);        
    #else
    EZI2C_EzI2CSetBuffer1(sizeof(I2Cbuf), RW, (void *) &I2Cbuf);     
    #endif   
    
    SmartIO_Start();    
    VDAC_Start();
    PVref_ALS_Start();
    Opamp_ALS1_Start();
    Opamp_ALS2_Start();
    PVref_Therm_Start();
    Opamp_Therm_Start();    
    ADC_Start();
    ADC_IRQ_Enable();
    
    CapSense_Start();   
    /* Over-ride IDAC values for buttons but keep auto for Prox and Humidity */
    CapSense_BUTTON0_IDAC_MOD0_VALUE =          7u;
    CapSense_BUTTON0_SNS0_IDAC_COMP0_VALUE =    6u;
    CapSense_BUTTON1_IDAC_MOD0_VALUE =          7u;
    CapSense_BUTTON1_SNS0_IDAC_COMP0_VALUE =    7u;
    CapSense_BUTTON2_IDAC_MOD0_VALUE =          9u;
    CapSense_BUTTON2_SNS0_IDAC_COMP0_VALUE =    7u;
    CapSense_BUTTON3_IDAC_MOD0_VALUE =          9u;
    CapSense_BUTTON3_SNS0_IDAC_COMP0_VALUE =    8u;
    /* Setup first widget and run the scan */    
    CapSense_SetupWidget(CapSense_BUTTON0_WDGT_ID);
    CapSense_Scan();      
    
    /* Start SysTick Timer to give a 1ms interrupt */
    CySysTickStart();
    /* Find unused callback slot and assign the callback. */
    for (i = 0u; i < CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)
    {
        if (CySysTickGetCallback(i) == NULL)
        {
            /* Set callback */
            CySysTickSetCallback(i, SysTickISRCallback);
            break;
        }
    }
    
    /* Initialize I2C and local data registers to 0's */
    I2Cbuf.dacVal = 0.0;
    I2Cbuf.ledVal = 0x00;
    I2Cbuf.ledControl = 0x00;
    I2Cbuf.buttonVal = 0x00;
    I2Cbuf.temperature = 0.0;
    I2Cbuf.humidity = 0.0;
    I2Cbuf.illuminance = 0.0;
    I2Cbuf.potVal = 0.0;
    
    LocData.dacVal = 0.0;
    LocData.ledVal = 0x00;
    LocData.ledControl = 0x00;
    LocData.buttonVal = 0x00;
    LocData.temperature = 0.0;
    LocData.humidity = 0.0;
    LocData.illuminance = 0.0;
    LocData.potVal = 0.0;
    
    for(;;)
    {
        processButtons();  /* Mechanical buttons and bootloader entry */
        processCapSense(); /* CapSense Scanning */
        processDAC();      /* VDAC output voltage setting */
        processADC();      /* Process ADC results after each scan completes */
        processI2C();      /* Copy date between I2C registers and local operating registers */
    }
} /* End of main */
Esempio n. 7
0
int main()
{
    uint8 loop;  
    	/* *** Start SPI bus. *** */
    SPI_Start();    
    SPI_SS_Write(1);  
    /* *** Turn off leds at startup. *** */
    Led_Red_Write(1);
    Led_Green_Write(1);
    Led_Blue_Write(1);
    
    /* *** Start serial port. *** */
    UART_Start();
    UART_PutString("\nPSoC RFM69 Test... PSoC 5LP...\n");
    
     
    
    /* *** Blink Red Led two times before starting RFM69 module. * ***/
    Led_Red_Write(0); CyDelay(250); Led_Red_Write(1); CyDelay(250);
    Led_Red_Write(0); CyDelay(250); Led_Red_Write(1); CyDelay(250);
    
    /* *** Start RFM69 module. Configure it. If the module is not found, program gets locked. 
           And red led gets turned on. If can find RFM module, then turn on green led. *** */
    UART_PutString("Looking for RFM69 module... ");
    
	if (RFM69_Start() != 1) 
    { 
        UART_PutString("FAILED\n\n");
        Led_Red_Write(0);
        while (1) {}; 
        
    }
    else 
    {
        UART_PutString("OK\n\n");
        Led_Green_Write(1);   
    }
    
    /* If testing with interrupts. But disabled until entering RX mode. */
    #ifdef TEST_USING_INTERRUPTS
        
        RFM_isr_StartEx(RFM69_IsrHandler);
        
    #endif    
    
    /* Start SysTick.
       When compiled for "MASTER" this is used to control timeout while in reception state. */
    CySysTickStart();   // interrupt every 1ms.
    
    /* Find unused callback slot. */
    for (loop = 0; loop < CY_SYS_SYST_NUM_OF_CALLBACKS; ++loop)
    {
        if (CySysTickGetCallback(loop) == NULL)
        {
            /* Set callback */
            CySysTickSetCallback(loop, SysTickIsrHandler);
            break;
        }
    }
    
    /* ----------------------------------------- */
    /* Configuration depending on node type.     */
    #ifdef COMPILE_FOR_MASTER
        Config_ForMaster();
    #endif

    #if defined COMPILE_FOR_SLAVE_1 || defined COMPILE_FOR_SLAVE_2
        Config_ForSlave();
    #endif
    /* ----------------------------------------- */    
    
    /* Uncomment next line and adjust params if you want to change bitrate at runtime. */
    RFM69_SetBitrateCls(BITRATE_MSB_9600, BITRATE_LSB_9600);
    
    /* If testing using encryption, change encryption mode and key at runtime. */
    #ifdef TEST_WITH_ENCRYPTION
        RFM69_Encryption(1, encryptionkey);
    #endif
   
    CyGlobalIntEnable; /* Enable global interrupts. */

    for(;;)
    {
        
        /* ----------------------------------------- */ 
        /* Call main loop depending on node type.    */
        #ifdef COMPILE_FOR_MASTER
                Loop_Master();
        #endif

        #if defined COMPILE_FOR_SLAVE_1 || defined COMPILE_FOR_SLAVE_2
                Loop_Slave();
        #endif
        /* ----------------------------------------- */

    }
}