Example #1
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();

    /* Initialize Drivers */
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();
 
    DRV_USART0_Initialize();
    DRV_USART1_Initialize();
    DRV_USART2_Initialize();
      
    /* Initialize System Services */
    SYS_INT_Initialize();  

    /* Initialize Middleware */
    initDebugU();

    /* Initialize the Application */
    COMMUNICATION_Initialize();
    MOTOR_Initialize();
    SENSORCOMMUNICATION_Initialize();
}
Example #2
0
void MOTOR_Initialize ( void )
{
    /* Place the App state machine in its initial state. */
    motorData.state = MOTOR_STATE_INIT;
        /* Place the App state machine in its initial state. */
	motorData.RxSeqNum = 0;
	motorData.TxSeqNum = 0;
	motorData.LEncode = 0;
	motorData.REncode = 0;
	motorData.REncodeTotal = 0;
	motorData.LEncodeTotal = 0;
	motorData.LDist = 0;
	motorData.RDist = 0;
	motorData.LSet = 0;
	motorData.RSet = 0;
	motorData.LMes = 0;
	motorData.RMes = 0;
	motorData.LAvg = 0.0;
	motorData.RAvg = 0;
	motorData.LOCSet = 0;
	motorData.ROCSet = 0;
	motorData.ratio = 0;
	motorData.RTestTick = 0;
	motorData.LTestTick = 0;
	motorData.n = 0;
	//motorData.rxMessage.command = 0;
	//motorData.rxMessage.duration = 0;
	motorData.theQueue = xQueueCreate(MOTORQUEUELENGTH, sizeof(MOTOR_MESSAGE)); //sizeof(appData.rxMessage));
	if(motorData.theQueue == 0)
	{
		crash("E:Create Motor msgQ");
		//failed to create queue
	}
	PLIB_PORTS_DirectionOutputSet(PORTS_ID_0, PORT_CHANNEL_G, 0x0002);
	PLIB_PORTS_DirectionOutputSet(PORTS_ID_0, PORT_CHANNEL_D, 0x0003);
	PLIB_PORTS_DirectionOutputSet(PORTS_ID_0, PORT_CHANNEL_C, 0x4000);
	PLIB_PORTS_PinWrite (PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_1, 0);
	PLIB_PORTS_PinWrite (PORTS_ID_0, PORT_CHANNEL_D, PORTS_BIT_POS_0, 0);

	DRV_OC1_Initialize();
	DRV_OC0_Initialize();
	//DRV_OC1_Enable();
	//DRV_OC0_Enable();	//same thing as start
	DRV_OC1_Stop();
	DRV_OC0_Stop();
	//25.6 us per count
	//count to 200 = 51.2ms per rollover
	DRV_TMR0_Initialize();	//OC Timer
	DRV_TMR1_Initialize();	//IC Timer
	DRV_TMR2_Initialize();	//duration Timer
	DRV_TMR0_CounterClear();
	DRV_TMR1_CounterClear();
	DRV_TMR2_CounterClear();
	DRV_TMR0_Stop();	//pwm timer
	DRV_TMR1_Stop();	//encoder timer 5ms
	DRV_TMR2_Stop();	//duration timer 1ms
	
//	theTimerInit(52);
}
Example #3
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();

    /* Initialize Drivers */
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();

    DRV_SPI0_Initialize();
    DRV_SPI1_Initialize();
    DRV_SPI2_Initialize();
    DRV_SPI3_Initialize();
    DRV_SPI4_Initialize();
    DRV_SPI5_Initialize();


    /*Initialize OC0 */
    DRV_OC0_Initialize();

    /*Initialize OC1 */
    DRV_OC1_Initialize();

    /*Initialize OC2 */
    DRV_OC2_Initialize();

    /*Initialize OC3 */
    DRV_OC3_Initialize();

    /*Initialize OC4 */
    DRV_OC4_Initialize();

    /*Initialize OC5 */
    DRV_OC5_Initialize();

    /*Initialize OC6 */
    DRV_OC6_Initialize();

    /*Initialize OC7 */
    DRV_OC7_Initialize();

    /*Initialize OC8 */
    DRV_OC8_Initialize();

    /* Initialize System Services */
    SYS_INT_Initialize();

    /* Initialize Middleware */
    /* Enable Global Interrupts */
    SYS_INT_Enable();

    /* Initialize the Application */
    APP_Initialize();
}
Example #4
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();

    /* Initialize Drivers */
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();
    /*Initialize TMR1 */
    DRV_TMR1_Initialize();
    /*Initialize TMR2 */
    DRV_TMR2_Initialize();
    /*Initialize TMR3 */
    DRV_TMR3_Initialize();

     DRV_USART0_Initialize();
    DRV_USART1_Initialize();


    /*Initialize OC0 */
    DRV_OC0_Initialize();

    /*Initialize OC1 */
    DRV_OC1_Initialize();

    /* Initialize System Services */
    SYS_INT_Initialize();  

    /*Setup the INT_SOURCE_EXTERNAL_1 and Enable it*/
    SYS_INT_VectorPrioritySet(INT_VECTOR_INT1, INT_PRIORITY_LEVEL1);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_INT1, INT_SUBPRIORITY_LEVEL0);
    SYS_INT_ExternalInterruptTriggerSet(INT_EXTERNAL_INT_SOURCE1,INT_EDGE_TRIGGER_RISING);
    SYS_INT_SourceEnable(INT_SOURCE_EXTERNAL_1);

    /*Setup the INT_SOURCE_EXTERNAL_2 and Enable it*/
    SYS_INT_VectorPrioritySet(INT_VECTOR_INT2, INT_PRIORITY_LEVEL1);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_INT2, INT_SUBPRIORITY_LEVEL0);
    SYS_INT_ExternalInterruptTriggerSet(INT_EXTERNAL_INT_SOURCE2,INT_EDGE_TRIGGER_RISING);
    SYS_INT_SourceEnable(INT_SOURCE_EXTERNAL_2);





    /* Initialize Middleware */
	initDebugU();

    /* Initialize the Application */
    COMMUNICATION_Initialize();
    MOTOR_Initialize();
}
Example #5
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();

    /* Initialize Drivers */
    /* Initialize ADC */
    DRV_ADC_Initialize();
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();
 
     DRV_USART0_Initialize();


    /*Initialize OC0 */
    DRV_OC0_Initialize();

    /*Initialize OC1 */
    DRV_OC1_Initialize();

    /*Initialize OC2 */
    DRV_OC2_Initialize();

    /*Initialize OC3 */
    DRV_OC3_Initialize();

    /* Initialize System Services */
    SYS_INT_Initialize();  

    /* Initialize Middleware */

    /* Initialize the Application */
    PWM_Initialize();
}
Example #6
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();

    /* Initialize Drivers */
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();
    /*Initialize TMR1 */
    DRV_TMR1_Initialize();
    /*Initialize TMR2 */
    DRV_TMR2_Initialize();
 
     sysObj.drvUsart0 = DRV_USART_Initialize(DRV_USART_INDEX_0, (SYS_MODULE_INIT *)&drvUsart0InitData);
    SYS_INT_VectorPrioritySet(INT_VECTOR_UART1, INT_PRIORITY_LEVEL3);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_UART1, INT_SUBPRIORITY_LEVEL1);


    /*Initialize OC0 */
    DRV_OC0_Initialize();

    /*Initialize OC1 */
    DRV_OC1_Initialize();

    /* Initialize System Services */
    SYS_INT_Initialize();  

    /* Initialize Middleware */

    /* Initialize the Application */
    APP_Initialize();
}
Example #7
0
void SYS_Initialize ( void* data )
{
    /* Core Processor Initialization */
    SYS_CLK_Initialize( NULL );
    sysObj.sysDevcon = SYS_DEVCON_Initialize(SYS_DEVCON_INDEX_0, (SYS_MODULE_INIT*)&sysDevconInit);
    SYS_DEVCON_PerformanceConfig(SYS_CLK_SystemFrequencyGet());
    SYS_DEVCON_JTAGDisable();
    SYS_PORTS_Initialize();
    
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_START); // has to be after ports init
#endif

    /* Initialize Drivers */
    /*Initialize TMR0 */
    DRV_TMR0_Initialize();
 
    DRV_USART0_Initialize();
    DRV_USART1_Initialize();
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_UART);
#endif
    

    /*Initialize OC0 */
    DRV_OC0_Initialize();

    /*Initialize OC1 */
    DRV_OC1_Initialize();

    /* Initialize System Services */
    SYS_INT_Initialize();  
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_SYS);
#endif

    /*Setup the INT_SOURCE_EXTERNAL_2 and Enable it*/
    SYS_INT_VectorPrioritySet(INT_VECTOR_INT2, INT_PRIORITY_LEVEL3);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_INT2, INT_SUBPRIORITY_LEVEL0);
    SYS_INT_ExternalInterruptTriggerSet(INT_EXTERNAL_INT_SOURCE2,INT_EDGE_TRIGGER_RISING);
    SYS_INT_SourceEnable(INT_SOURCE_EXTERNAL_2);

    /*Setup the INT_SOURCE_EXTERNAL_1 and Enable it*/
    SYS_INT_VectorPrioritySet(INT_VECTOR_INT1, INT_PRIORITY_LEVEL3);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_INT1, INT_SUBPRIORITY_LEVEL0);
    SYS_INT_ExternalInterruptTriggerSet(INT_EXTERNAL_INT_SOURCE1,INT_EDGE_TRIGGER_RISING);
    SYS_INT_SourceEnable(INT_SOURCE_EXTERNAL_1);

    /*Setup the INT_SOURCE_EXTERNAL_3 and Enable it*/
    SYS_INT_VectorPrioritySet(INT_VECTOR_INT3, INT_PRIORITY_LEVEL3);
    SYS_INT_VectorSubprioritySet(INT_VECTOR_INT3, INT_SUBPRIORITY_LEVEL0);
    SYS_INT_ExternalInterruptTriggerSet(INT_EXTERNAL_INT_SOURCE3,INT_EDGE_TRIGGER_RISING);
    SYS_INT_SourceEnable(INT_SOURCE_EXTERNAL_3);




    /* Initialize Middleware */

    /* Initialize the Application */
    MOTORAPP_Initialize();
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_APP);
#endif
    UART_TX_APP_Initialize();
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_UART_TX_APP);
#endif
    UART_RX_APP_Initialize();
#ifdef DEBUG_ON
    setDebugVal(SYS_INIT_UART_RX_APP);
#endif
}