Esempio n. 1
0
/*---------------------------------------------------------------------------*
 * Routine:  UEZGUI_EXP_DK_FullDuplex_RS485_Require
 *---------------------------------------------------------------------------*
 * Description:
 *      Setup a full duplex RS485 connection.
 *---------------------------------------------------------------------------*/
void UEZGUI_EXP_DK_FullDuplex_RS485_Require(
    TUInt32 aWriteBufferSize,
    TUInt32 aReadBufferSize)
{
    // Need UART A without a stream
    UEZPlatform_ExpansionPrimary_UART_A_Require();

    // Ensure the drive enable pin is always HIGH
    if (GPIO_EXPDK_485DE != GPIO_NONE) {
        UEZGPIOSetMux(GPIO_EXPDK_485DE, 0);
        UEZGPIOSet(GPIO_EXPDK_485DE);
        UEZGPIOOutput(GPIO_EXPDK_485DE);
        UEZGPIOLock(GPIO_EXPDK_485DE);
    }

    // Ensure the receive enable pin is always low
    if (GPIO_EXPDK_485RE != GPIO_NONE) {
        // Drive enable pin must be LOW
        UEZGPIOSetMux(GPIO_EXPDK_485RE, 0);
        UEZGPIOClear(GPIO_EXPDK_485RE);
        UEZGPIOOutput(GPIO_EXPDK_485RE);
        UEZGPIOLock(GPIO_EXPDK_485RE);
    }

    Serial_Generic_FullDuplex_Stream_Create("EXP_RS485",
        PRIMARY_EXPANSION_UART_A, aWriteBufferSize, aReadBufferSize);
}
Esempio n. 2
0
/*---------------------------------------------------------------------------*
 * Routine:  Open
 *---------------------------------------------------------------------------*
 * Description:
 *     Initalizes pins for the audio amp 
 *     turns it on
 *     sets the level to the default
 * Inputs:
 *      void *aWorkSpace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_Open(void *aWorkSpace)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;
    TUInt8 i, setLevel;

    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    p->iNumOpen++;

    if (!(p->iIsOn)) {
        setLevel = ((p->iLevel * (p->iMaxLevel - p->iMinLevel))/0xFF) + p->iMinLevel;
        p->iIsOn = ETrue;
        UEZGPIOOutput(p->iModeGPIO);
        UEZGPIOSetMux(p->iModeGPIO, 0); // set to GPIO
        UEZGPIOClear(p->iModeGPIO); // Turn on the amp
        UEZGPIOOutput(p->iVolumeGPIO);
        UEZGPIOSetMux(p->iVolumeGPIO, 0); // set to GPIO

        for (i = HIGH_LEVEL; i > 0; i--) {
            UEZGPIOClear(p->iVolumeGPIO); // set low to go down
            UEZGPIOOutput(p->iVolumeGPIO); // set to output
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOSet(p->iVolEnableGPIO);
            UEZTaskDelay(1);
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOClear(p->iVolEnableGPIO);
            UEZGPIOInput(p->iVolumeGPIO); // set to input
            UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
            UEZTaskDelay(1);
        }

        for (i = LOW_LEVEL; i < setLevel; i++) {
            UEZGPIOSet(p->iVolumeGPIO); // set low to go down
            UEZGPIOOutput(p->iVolumeGPIO); // set to output
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOSet(p->iVolEnableGPIO);
            UEZTaskDelay(1);
            if (p->iVolEnableGPIO != GPIO_NONE)
                UEZGPIOClear(p->iVolEnableGPIO);
            UEZGPIOInput(p->iVolumeGPIO); // set to input
            UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
            UEZTaskDelay(1);
        }
    }
    if (p->iVolEnableGPIO != GPIO_NONE)
        UEZGPIOClear(p->iVolEnableGPIO);

    UEZSemaphoreRelease(p->iSem);
    return UEZ_ERROR_NONE;
}
Esempio n. 3
0
/*---------------------------------------------------------------------------*
 * Routine:  LCD_RH320240T_Open
 *---------------------------------------------------------------------------*
 * Description:
 *      Start the LCD screen.  If this is the first open, initialize the
 *      screen.
 * Inputs:
 *      void *aW                -- Workspace
 * Outputs:
 *      T_uezError               -- If the device is opened, returns
 *                                  UEZ_ERROR_NONE.
 *---------------------------------------------------------------------------*/
T_uezError LCD_RH320240T_Open(void *aW)
{
    T_RH320240TWorkspace *p = (T_RH320240TWorkspace *)aW;
    HAL_LCDController **plcdc;
    T_uezError error = UEZ_ERROR_NONE;

    p->aNumOpen++;
    if (p->aNumOpen == 1) {
        plcdc = p->iLCDController;

        // Choose a settings based on the configuration
        switch (p->iConfiguration->iColorDepth) {
            case UEZLCD_COLOR_DEPTH_8_BIT:
                LCD_RH320240T_settings = LCD_RH320240T_params8bit;
                break;
            default:
            case UEZLCD_COLOR_DEPTH_16_BIT:
                LCD_RH320240T_settings = LCD_RH320240T_params16bit;
                break;
            case UEZLCD_COLOR_DEPTH_I15_BIT:
                LCD_RH320240T_settings = LCD_RH320240T_paramsI15bit;
                break;
        }

        LCD_RH320240T_settings.iBaseAddress = p->iBaseAddress;

        // Turn on LCD controller and output power pin
        // Programs SPI first after power up
        error = (*plcdc)->Configure(plcdc, &LCD_RH320240T_settings);

// Testing
(*p->iLCDController)->On(p->iLCDController); // turns on data next

        UEZGPIOSetMux(p->iSHUTGPIOPin, 0);
        UEZGPIOSet(p->iSHUTGPIOPin);
        UEZGPIOOutput(p->iSHUTGPIOPin);

        // Drop SHUT down to be a low (active)
        UEZGPIOClear(p->iSHUTGPIOPin);

        // What does data enable pin do? high or low? It doesn't appear to be needed.
//      UEZGPIOSetMux(p->iENBGPIOPin, 0);
//      UEZGPIOClear(p->iENBGPIOPin);
//      UEZGPIOSet(p->iENBGPIOPin);
//      UEZGPIOOutput(p->iENBGPIOPin);

        // Configure SPI
        LCD_ConfigureSPI(p);

        return error;
    }

    return UEZ_ERROR_NONE;
}
Esempio n. 4
0
/*---------------------------------------------------------------------------*
 * Routine:  uEZPlatformStartup
 *---------------------------------------------------------------------------*
 * Description:
 *      When uEZ starts, a special Startup task is created and called.
 *      This task brings up the all the hardware, reports any problems,
 *      starts the main task, and then exits.
 *---------------------------------------------------------------------------*/
TUInt32 uEZPlatformStartup(T_uezTask aMyTask, void *aParameters)
{
    extern T_uezTask G_mainTask;

    UEZPlatform_Standard_Require();
    SUIInitialize(SIMPLEUI_DOUBLE_SIZED_ICONS, EFalse, EFalse); // SWIM not flipped

    // USB Flash drive host mode needed?
#if USB_PORT_B_HOST_DETECT_ENABLED
    UEZGPIOLock(GPIO_P0_12);
    UEZGPIOSet(GPIO_P0_12); // disable MIC2025
    UEZGPIOOutput(GPIO_P0_12);
    UEZGPIOInput(GPIO_P0_28);
    UEZGPIOSetMux(GPIO_P0_28, 0);
    G_usbIsDevice = UEZGPIORead(GPIO_P0_28);
    if (G_usbIsDevice) {
        // High for a device
        UEZPlatform_USBDevice_Require();
    } else {
        // Low for a host
#if UEZ_ENABLE_USB_HOST_STACK
        UEZPlatform_USBFlash_Drive_Require(0);
#endif
        UEZGPIOClear(GPIO_P0_12); // enable MIC2025
    }
#else
    G_usbIsDevice = ETrue;
    // USB Device needed?
    UEZPlatform_USBDevice_Require();
#endif
    
#if UEZ_ENABLE_USB_HOST_STACK
    // USB Host is required
    UEZPlatform_USBFlash_Drive_Require(0);
#endif
    
    // SDCard needed?
    UEZPlatform_SDCard_Drive_Require(1);

    // Network needed?
#if UEZ_ENABLE_WIRED_NETWORK
    UEZPlatform_WiredNetwork0_Require();
#endif

    // Create a main task (not running yet)
    UEZTaskCreate((T_uezTaskFunction)MainTask, "Main", MAIN_TASK_STACK_SIZE, 0,
            UEZ_PRIORITY_NORMAL, &G_mainTask);

    // Done with this task, fall out
    return 0;
}
Esempio n. 5
0
/*---------------------------------------------------------------------------*
 * Routine: SetLevel
 *---------------------------------------------------------------------------*
 * Description: 
 *      Set the gain of the audio amp to the desired level
 * Inputs:
 *      void *aWorkspace
 *      TUInt8 aLevel             --new level to set the amp to
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_SetLevel(void *aWorkSpace, TUInt8 aLevel)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;
    TUInt8 i, setLevel, oldLevel;

    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    oldLevel = ((((p->iLevel * 100) / (0xFF)) * (p->iMaxLevel - p->iMinLevel))/100) + p->iMinLevel;
    p->iLevel = aLevel;
    setLevel = ((p->iLevel * (p->iMaxLevel - p->iMinLevel))/0xFF) + p->iMinLevel;

    UEZGPIOSetMux(p->iVolumeGPIO, 0); // set to GPIO

    if (setLevel != oldLevel) {
        if (oldLevel < setLevel) {
            for (i = oldLevel; i < setLevel; i++) {
                UEZGPIOSet(p->iVolumeGPIO); //set High to go up
                UEZGPIOOutput(p->iVolumeGPIO); //set to output
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOSet(p->iVolEnableGPIO);
                UEZTaskDelay(1);
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOClear(p->iVolEnableGPIO);
                UEZGPIOInput(p->iVolumeGPIO);
                UEZGPIOClear(p->iVolumeGPIO);
                UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
                UEZTaskDelay(1);
            }
        } else {
            for (i = oldLevel; i > setLevel; i--) {
                UEZGPIOClear(p->iVolumeGPIO); //set low to go down
                UEZGPIOOutput(p->iVolumeGPIO); //set to output
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOSet(p->iVolEnableGPIO);
                UEZTaskDelay(1);
                if (p->iVolEnableGPIO != GPIO_NONE)
                    UEZGPIOClear(p->iVolEnableGPIO);
                UEZGPIOInput(p->iVolumeGPIO);
                UEZGPIOSetPull(p->iVolumeGPIO, GPIO_PULL_NONE);
                UEZTaskDelay(1);
            }
        }
        p->iLevel = aLevel;
    }

    if (p->iVolEnableGPIO != GPIO_NONE)
        UEZGPIOClear(p->iVolEnableGPIO);
    UEZSemaphoreRelease(p->iSem);
    return UEZ_ERROR_NONE;
}
Esempio n. 6
0
void CANConfigure ( void )
{
#if (UEZ_PROCESSOR==NXP_LPC2478)
        UEZGPIOSetMux(GPIO_P0_0, 1);
        UEZGPIOSetMux(GPIO_P0_1, 1);
//    unsigned int n = ((Fcclk/4)/125000)-1;
    PCONP |= PCONP_PCAN1;
    PCLKSEL0 |= (2<<PCLKSEL0_PCLK_CAN1_BIT)|(2<<PCLKSEL0_PCLK_ACF_BIT);
        C1MOD        =        0x00000001;        /* Set CAN controller into reset */
        C1BTR        =        0x001C0011;        /* Set bit timing to 125k -- old value from 2119 0x1D */
        C1IER        =        0x00000000;        /* Disable the Receive interrupt */
        AFMR        =        0x00000002;        /* Bypass acceptance filters to receive all CAN traffic */
        C1TFI1        =        0x00080000;        /* Set DLC to transmit 8 bytes */        
        C1TID1        =        0x00000555;        /* Set CAN ID to '555' */
#if 1
        C1MOD        =        0x00000000;        /* Release CAN controller */
#endif
#endif
#if (UEZ_PROCESSOR==NXP_LPC1788)
        UEZGPIOSetMux(GPIO_P0_0, 1);
        UEZGPIOSetMux(GPIO_P0_1, 1);
//    unsigned int n = ((Fcclk/4)/125000)-1;
    //PCONP |= PCONP_PCAN1;
    LPC17xx_40xxPowerOn(1<<13); // CAN1 power on
    //PCLKSEL0 |= (2<<PCLKSEL0_PCLK_CAN1_BIT)|(2<<PCLKSEL0_PCLK_ACF_BIT);
    LPC_CAN1->MOD        =        0x00000001;        /* Set CAN controller into reset */
    LPC_CAN1->BTR        =        0x001C0000|(30-1);        /* Set bit timing to 125k -- old value from 2119 0x1D */
    LPC_CAN1->IER        =        0x00000000;        /* Disable the Receive interrupt */
    LPC_CANAF->AFMR      =        0x00000002;        /* Bypass acceptance filters to receive all CAN traffic */
    LPC_CAN1->TFI1        =        0x00080000;        /* Set DLC to transmit 8 bytes */        
    LPC_CAN1->TID1        =        0x00000555;        /* Set CAN ID to '555' */
#if 1
    LPC_CAN1->MOD        =        0x00000000;        /* Release CAN controller */
#endif
#endif
        G_canConfigured = 1;
}
Esempio n. 7
0
/*---------------------------------------------------------------------------*
 * Routine:  UnMute
 *---------------------------------------------------------------------------*
 * Description:
 *     Takes the amp out of standby mode
 * Inputs:
 *      void *aWorkSpace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_UnMute(void *aWorkSpace)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;

    UEZSemaphoreGrab(p->iSem, UEZ_TIMEOUT_INFINITE);

    if (p->iIsMuted) {
        p->iIsMuted = EFalse;
        UEZGPIOSetMux(p->iModeGPIO, 0); // set to GPIO
        UEZGPIOClear(p->iModeGPIO);
    }

    UEZSemaphoreRelease(p->iSem);

    return UEZ_ERROR_NONE;
}
Esempio n. 8
0
/*---------------------------------------------------------------------------*
 * Routine:  UEZGUI_EXP_DK_USB_Host_Port_B_Detect
 *---------------------------------------------------------------------------*
 * Description:
 *      Detect USB Host mode on mini-AB port using OTG adapter ID pin to GND
 *---------------------------------------------------------------------------*/
TBool UEZGUI_EXP_DK_USB_Host_Port_B_Detect()
{
    TBool IsDevice;

    UEZGPIOLock(GPIO_USB_HOST_ENABLE); // P0_12 on LPC1788 uEZGUIs
    UEZGPIOSet(GPIO_USB_HOST_ENABLE); // disable MIC2025 power for USB
    UEZGPIOOutput(GPIO_USB_HOST_ENABLE);
    UEZGPIOInput(GPIO_EXPDK_USBDID);
    UEZGPIOSetMux(GPIO_EXPDK_USBDID, 0);

    IsDevice = UEZGPIORead(GPIO_EXPDK_USBDID);

    if(!IsDevice){
        UEZGPIOClear(GPIO_USB_HOST_ENABLE);// enable MIC2025 USB Power
    }
    return IsDevice;
}
Esempio n. 9
0
/*---------------------------------------------------------------------------*
 * Routine:  TS_EXC7200_Configure
 *---------------------------------------------------------------------------*
 * Description:
 *      The SPI bus and GPIO device are being declared.
 * Inputs:
 *      void *aW                    -- Particular SPI workspace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError TS_EXC7200_Configure(T_uezDeviceWorkspace *aW)
{
    T_EXC7200Workspace *p = (T_EXC7200Workspace *)aW;

    UEZSemaphoreGrab(p->iSemWaitForTouch, 0);

    UEZGPIOSetMux(p->iResetPin, 0);//Set to GPIO
    UEZGPIOOutput(p->iResetPin);
    UEZGPIOClear(p->iResetPin);

    UEZTaskDelay(1);
    UEZGPIOConfigureInterruptCallback(
        UEZ_GPIO_PORT_FROM_PORT_PIN(p->iInteruptPin),
        TS_EXC7200_InterruptISR,
        p);
    UEZGPIOEnableIRQ(p->iInteruptPin, GPIO_INTERRUPT_FALLING_EDGE);

    UEZGPIOSet(p->iResetPin);
    
    T_uezDevice i2c;
    I2C_Request request;
    T_uezError error;
    TUInt8 dataIn[10];
    TUInt8 dataOut[10] = { 0x03, 0x06, 0x0A, 0x04, 0x36, 0x3f, 0x01, 9, 0, 0};

    request.iAddr = EXC7200_I2C_ADDRESS;
    request.iSpeed = EXC7200_I2C_SPEED;
    request.iReadData = dataIn;
    request.iReadLength = 10;
    request.iWriteData = dataOut;
    request.iWriteLength = 10;

    UEZI2COpen(p->iI2CBus, &i2c);
    error = UEZI2CTransaction(i2c, &request);
                      

    return UEZ_ERROR_NONE;
}
Esempio n. 10
0
/*---------------------------------------------------------------------------*
 * Routine:  Close
 *---------------------------------------------------------------------------*
 * Description:
 *     Puts the device in standby when iNumOpen is 0
 * Inputs:
 *      void *aWorkSpace
 * Outputs:
 *      T_uezError                   -- Error code
 *---------------------------------------------------------------------------*/
T_uezError AudioAmp_8551T_Close(void *aWorkSpace)
{
    T_AudioAmp_8551T_Workspace *p = (T_AudioAmp_8551T_Workspace *)aWorkSpace;

    if (p->iIsOn) {
        p->iNumOpen--;
    }

    if (p->iNumOpen == 0) {
        UEZGPIOOutput(p->iModeGPIO);
        UEZGPIOSetMux(p->iModeGPIO, 0); // set to GPIO
        UEZGPIOSet(p->iModeGPIO); // set to standby
        p->iIsOn = EFalse;
        p->iIsMuted = EFalse;
        p->iLevel = DEFAULT_LEVEL;
    }
    if (p->iVolEnableGPIO != GPIO_NONE)
        UEZGPIOClear(p->iVolEnableGPIO);

    UEZSemaphoreRelease(p->iSem);

    return UEZ_ERROR_NONE;
}