Пример #1
0
void InitApp(void)
{
    /* Setup analog functionality and port direction */

    // enable multi-vector interrupts
    INTEnableSystemMultiVectoredInt();

    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // STEP 2. configure Timer 1 using internal clock, 1:256 prescale

    OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, T1_TICK);

    // set up the timer interrupt with a priority of 2
    ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
    
    /* Zero to DELAY_COUNTER for Delay procedure. */
    StartTimer();

    /* Initialize peripherals */

    DisplayBacklightConfig();

//#if defined WANT_GOL_INIT
    GOLInit();
//#endif

//    TouchInit(NULL,NULL,NULL,NULL);

    DisplayBacklightOn();

    SPIFlashInit();
    
// initialize the components for Resistive Touch Screen
//#if defined WANT_TOUCH_INIT
//    TouchInit(NULL,NULL,NULL,NULL);
//#endif
//    SDCARDInit();
//    MP3Init();

    /* PORT Init                                                            */
    /* PORTD 0-3 bits inputs.                                               */
    /* PORTA 0-1 bits outputs.                                              */

    /* TODO Must be disable the JTAG port, that we are to appropriate using */
    /* RA0, and RA1 ports.  */

    DDPCONbits.JTAGEN = 0;  /* JTAG debug disabled */
    /* TODO D port output now !!!! */
    TRISDbits.TRISD14 = TRISDbits.TRISD15 = 0;
        /* Port D 14, 15, pins pull up resistor enabled */
//    CNPUEbits.CNPUE20 = CNPUEbits.CNPUE21 = 1;
    TRISAbits.TRISA0 = TRISAbits.TRISA1 = 0;

}
Пример #2
0
// *****************************************************************************
// void SYSTEM_InitializeBoard(void)
// *****************************************************************************
void SYSTEM_InitializeBoard(void)
{

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();


    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------
    DRV_GFX_Initialize();


}
Пример #3
0
void SYSTEM_InitializeBoard(void)
{
    const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0};

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();

    // ---------------------------------------------------------
    // mikroe Board
    // SPI-Flash Device pins
    // ---------------------------------------------------------
    // chip select pin
    SST25_CS_TRIS   = 0;
    SST25_CS_LAT    = 1;
    // spi-clock pin
    SST25_SCK_TRIS  = 0;
    // spi-output pin
    SST25_SDO_TRIS  = 0;
    // spi-intput pin
    SST25_SDI_TRIS  = 1;

    /* Config the LED ports to output. */
    LEDPortsConfig();
    LEDPortsClear();
    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------

    DRV_GFX_Initialize();

    DRV_NVM_M25P80_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data);

    // initialize system tick counter
    SYSTEM_TickInit();

    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL);
//    TouchInit(NULL, NULL, NULL, NULL);

}
Пример #4
0
// *****************************************************************************
// void SYSTEM_InitializeBoard(void)
// *****************************************************************************
void SYSTEM_InitializeBoard(void)
{
    // SPI initialization for Serial RAM
    const DRV_SPI_INIT_DATA SRAM_SPI_Init_Data = {
                                2, 3,
                                7, 1,
                                SPI_BUS_MODE_1, 0};

    // SPI initialization for EPD
    const DRV_SPI_INIT_DATA EPD_SPI_Init_Data = {
                                1, 3,
                                7, 1,
                                SPI_BUS_MODE_1, 0};

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();

    // ---------------------------------------------------------
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    // ---------------------------------------------------------
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;

    // ---------------------------------------------------------
    // EPD PicTail Plus Daughter Board 23K256
    // SPI-RAM Device Chip Select pin
    // ---------------------------------------------------------
    MCHP_23K256_CS_TRIS = 0;
    MCHP_23K256_CS_LAT  = 1;

    // ---------------------------------------------------------
    // EPD PicTail Plus Daughter
    // Board EPD Controller Device Chip Select pin
    // ---------------------------------------------------------
    DRV_EPD_SPI_CS_TRIS     = 0;
    DRV_EPD_SPI_CS_LAT     = 1;

    // ---------------------------------------------------------
    // SPI Port pins
    // ---------------------------------------------------------
    // spi-clock pin
    TRISFbits.TRISF6 = 0;
    // spi-output pin
    TRISFbits.TRISF8 = 0;
    // spi-intput pin
    TRISFbits.TRISF7 = 1;

    // initialize SPI driver
    DRV_RAM_23K256_Initialize((DRV_SPI_INIT_DATA*)&SRAM_SPI_Init_Data);

    // initialize EPD driver
    DRV_EPD_SPI_Initialize((DRV_SPI_INIT_DATA*)&EPD_SPI_Init_Data);

    // Initialize the e-paper (EPD)
    EPD_display_init();

    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------
    DRV_GFX_Initialize();
    GFX_Initialize();
    
    // Initialize the reference timer.
    SYSTEM_TickInit();    


}
Пример #5
0
// *****************************************************************************
void SYSTEM_InitializeBoard(void)
{

    const DRV_SPI_INIT_DATA SPI_Init_Data = {2, 3, 7, 0, SPI_BUS_MODE_3, 0};

    // ---------------------------------------------------------
    // Make sure the display DO NOT flicker at start up
    // ---------------------------------------------------------
    DisplayBacklightConfig();
    DisplayPowerConfig();
    DisplayBacklightOff();
	
    // ---------------------------------------------------------
    // ADC Explorer 16 Development Board Errata (work around 2)
    // RB15 should be output
    // ---------------------------------------------------------
    LATBbits.LATB15 = 0;
    TRISBbits.TRISB15 = 0;

    // ---------------------------------------------------------
    // Explorer 16 Development Board MCHP25LC256 chip select signal,
    // even if not used must be driven to high so it does not
    // interfere with other SPI peripherals that uses the same SPI signals.
    // ---------------------------------------------------------
    TRISDbits.TRISD12 = 0;
    LATDbits.LATD12 = 1;
    
    // ---------------------------------------------------------
    // Graphics LCD Controller PICtail Plus SSD1926 Board
    // SPI-Flash Device pins 
    // ---------------------------------------------------------
    // chip select pin
    TRISDbits.TRISD1 = 0;
    LATDbits.LATD1   = 1;
    // spi-clock pin
    TRISGbits.TRISG6 = 0;
    // spi-output pin
    TRISGbits.TRISG8 = 0;
    // spi-intput pin
    TRISGbits.TRISG7 = 1;

    // ---------------------------------------------------------
    // UART pins
    // ---------------------------------------------------------
    // initialize the UART pins
    TRISFbits.TRISF5 = 0;
    TRISFbits.TRISF4 = 1;

    // unlock PPS
    __builtin_write_OSCCONL(OSCCON & 0xbf);

    // set UART pins
    RPINR19bits.U2RXR = 10; 	// assign RP10 to RX
    RPOR8bits.RP17R = 5;    	// assign RP17 to TX

    // set SPI pins
    RPOR10bits.RP21R = 11;      // assign RP21 for SCK2
    RPOR9bits.RP19R = 10;       // assign RP19 for SDO2
    RPINR22bits.SDI2R = 26;     // assign RP26 for SDI2

    // lock   PPS
    __builtin_write_OSCCONL(OSCCON | 0x40);

    // ---------------------------------------------------------
    // Initialize the Display Driver
    // ---------------------------------------------------------
    DRV_GFX_Initialize();

    DRV_NVM_SST25VF016_Initialize((DRV_SPI_INIT_DATA*)&SPI_Init_Data);

    // initialize system tick counter
    SYSTEM_TickInit();

    // initialize the components for Resistive Touch Screen
    TouchInit(NVMWrite, NVMRead, NVMSectorErase, NULL);

    
}
Пример #6
0
/*
*********************************************************************************************************
*                                          ApplicationInitialize
*
* Description :  This function is called by SYS_Initialize() function and run after power up.  Global 
*                interrupts are not enabled here (i.e. CP0 Status register).  Interrupts will be enabled 
*                by RTOS when the highest priority task is run for the first time.
* Arguments   : 
*********************************************************************************************************
*/
void ApplicationInitialize ( void )
{
   portBASE_TYPE errStatus;
   
   /*initialize app_data object to initial values for this application*/
   appData.deviceHandle = USB_DEVICE_HANDLE_INVALID;
   appData.isConfigured = false;
   /* Initialize the keycode array */
   appData.key = USB_HID_KEYBOARD_KEYPAD_KEYBOARD_A;
   appData.keyCodeArray.keyCode[0] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   appData.keyCodeArray.keyCode[1] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   appData.keyCodeArray.keyCode[2] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   appData.keyCodeArray.keyCode[3] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   appData.keyCodeArray.keyCode[4] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   appData.keyCodeArray.keyCode[5] = USB_HID_KEYBOARD_KEYPAD_RESERVED_NO_EVENT_INDICATED;
   /* Initialize the modifier keys */
   appData.keyboardModifierKeys.modifierkeys = 0;
   /* Initialise the led state */
   appData.keyboardOutputReport.data = 0;
   /* Intialize the switch state */
   appData.isSwitchPressed = false;
   appData.ignoreSwitchPress = false;
   /* Initialize the HID instance index.  */
   appData.hidInstance = 0;
   /* Initialize tracking variables */
   appData.isReportReceived = false;
   appData.isReportSentComplete = true;
   /* Initialize the application state*/
   appData.state = APP_STATE_INIT;
   
   /*write proper hardware pins to setup gfx*/
   DisplayResetEnable();
   DisplayResetConfig();
   DisplayCmdDataConfig();
   DisplayConfig();
   DisplayBacklightOff();
   DisplayBacklightConfig();
   
   /*create applicaiton specific tasks*/
   errStatus = xTaskCreate((pdTASK_CODE) ApplicationLEDblinkTask,
                (const signed char*)"LED Blink Task",
                APPLICATION_LEDBLINKTASK_STKSIZE,
                NULL,
                APPLICATION_LEDBLINKTASK_PRIO,
                NULL);

   errStatus = xTaskCreate((pdTASK_CODE) ApplicationUSBDeviceTask,
                (const signed char*)"USB Device Task",
                APPLICATION_USBDEVICETASK_STKSIZE,
                NULL,
                APPLICATION_USBDEVICETASK_PRIO,
                NULL);
    errStatus = xTaskCreate((pdTASK_CODE) ApplicationDisplayTask,
                (const signed char*)"Display Task",
                APPLICATION_DISPLAYTASK_STKSIZE,
                NULL,
                APPLICATION_DISPLAYTASK_PRIO,
                NULL);

   /*setup up interrupt controller to use multi-vectored mode, this is not the internal CP0 register,
   this sets the SFR register*/
   PLIB_INT_MultiVectorSelect(INT_ID_0);
   /* Set priority for USB interrupt source */                                
   PLIB_INT_VectorPrioritySet(INT_ID_0,INT_VECTOR_USB,INT_PRIORITY_LEVEL4);
}