mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added functions for PD-LED boards.
This commit is contained in:
@@ -537,7 +537,47 @@ PINPROC_API PRResult PRJTAGReadTDIMemory(PRHandle handle, uint16_t tableOffset,
|
||||
/** Read the JTAG status register for the command complete bit and JTAG pin states. */
|
||||
PINPROC_API PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
|
||||
|
||||
/** @} */ // End of DMD
|
||||
/** @} */ // End of JTAG
|
||||
|
||||
// PD-LED
|
||||
|
||||
/**
|
||||
* @defgroup pdled PD-LED Control
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum PRLEDRegisterType {
|
||||
kPRLEDRegisterTypeLEDIndex = 0,
|
||||
kPRLEDRegisterTypeColor = 1,
|
||||
kPRLEDRegisterTypeFadeColor = 2,
|
||||
kPRLEDRegisterTypeFadeRateLow = 3,
|
||||
kPRLEDRegisterTypeFadeRateHigh = 4
|
||||
} PRPDLEDRegisterType;
|
||||
|
||||
typedef struct PRLED {
|
||||
uint8_t boardAddr;
|
||||
uint8_t LEDIndex;
|
||||
} PRLED;
|
||||
|
||||
typedef struct PRLEDRGB {
|
||||
PRLED* pRedLED;
|
||||
PRLED* pGreenLED;
|
||||
PRLED* pBlueLED;
|
||||
} PRLEDRGB;
|
||||
|
||||
/** Sets the color of a given PRLED. */
|
||||
PINPROC_API PRResult PRLEDColor(PRHandle handle, PRLED * pLED, uint8_t color);
|
||||
/** Sets the fade color and rate on a given PRLED. */
|
||||
PINPROC_API PRResult PRLEDFade(PRHandle handle, PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate);
|
||||
|
||||
/** Sets the color of a given PRLEDRGB. */
|
||||
PINPROC_API PRResult PRLEDRGBColor(PRHandle handle, PRLEDRGB * pLED, uint32_t color);
|
||||
/** Sets the fade color and rate on a given PRLEDRGB. */
|
||||
PINPROC_API PRResult PRLEDRGBFade(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate);
|
||||
|
||||
|
||||
/** @} */ // End of PD-LED
|
||||
|
||||
|
||||
/** @cond */
|
||||
PINPROC_EXTERN_C_END
|
||||
|
||||
@@ -567,3 +567,59 @@ PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status)
|
||||
{
|
||||
return handleAsDevice->PRJTAGGetStatus(status);
|
||||
}
|
||||
|
||||
void FillLEDCommand(uint8_t boardAddr, uint8_t LEDIndex, PRLEDRegisterType reg, uint8_t value, uint32_t * pData)
|
||||
{
|
||||
pData[0] = (0x1 << 24) | (boardAddr << 16) | (kPRLEDRegisterTypeLEDIndex << 8) | LEDIndex;
|
||||
pData[1] = (0x1 << 24) | (boardAddr << 16) | (reg << 8) | value;
|
||||
}
|
||||
|
||||
PRResult PRLEDColor(PRHandle handle, PRLED * pLED, uint8_t color)
|
||||
{
|
||||
uint32_t data[2];
|
||||
|
||||
FillLEDCommand(pLED->boardAddr, pLED->LEDIndex, kPRLEDRegisterTypeColor, color, data);
|
||||
|
||||
return PRWriteData(handle, 3, 0xc00, 2, data);
|
||||
}
|
||||
|
||||
PRResult PRLEDFade(PRHandle handle, PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate)
|
||||
{
|
||||
uint32_t data[6];
|
||||
|
||||
FillLEDCommand(pLED->boardAddr, pLED->LEDIndex, kPRLEDRegisterTypeFadeColor, fadeColor, data);
|
||||
FillLEDCommand(pLED->boardAddr, pLED->LEDIndex, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[2]);
|
||||
FillLEDCommand(pLED->boardAddr, pLED->LEDIndex, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[4]);
|
||||
|
||||
return PRWriteData(handle, 3, 0xc00, 6, data);
|
||||
}
|
||||
|
||||
PRResult PRLEDRGBColor(PRHandle handle, PRLEDRGB * pLED, uint32_t color)
|
||||
{
|
||||
uint32_t data[6];
|
||||
|
||||
FillLEDCommand(pLED->pRedLED->boardAddr, pLED->pRedLED->LEDIndex, kPRLEDRegisterTypeColor, (color >> 16) & 0xFF, data);
|
||||
FillLEDCommand(pLED->pGreenLED->boardAddr, pLED->pGreenLED->LEDIndex, kPRLEDRegisterTypeColor, (color >> 8) & 0xFF, &data[2]);
|
||||
FillLEDCommand(pLED->pBlueLED->boardAddr, pLED->pBlueLED->LEDIndex, kPRLEDRegisterTypeColor, color & 0xFF, &data[4]);
|
||||
|
||||
return PRWriteData(handle, 3, 0xc00, 6, data);
|
||||
}
|
||||
|
||||
PRResult PRLEDRGBFade(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate)
|
||||
{
|
||||
uint32_t data[18];
|
||||
|
||||
FillLEDCommand(pLED->pRedLED->boardAddr, pLED->pRedLED->LEDIndex, kPRLEDRegisterTypeFadeColor, (fadeColor >> 16) & 0xFF, data);
|
||||
FillLEDCommand(pLED->pRedLED->boardAddr, pLED->pRedLED->LEDIndex, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[2]);
|
||||
FillLEDCommand(pLED->pRedLED->boardAddr, pLED->pRedLED->LEDIndex, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[4]);
|
||||
|
||||
FillLEDCommand(pLED->pGreenLED->boardAddr, pLED->pGreenLED->LEDIndex, kPRLEDRegisterTypeFadeColor, (fadeColor >> 8) & 0xFF, &data[6]);
|
||||
FillLEDCommand(pLED->pGreenLED->boardAddr, pLED->pGreenLED->LEDIndex, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[8]);
|
||||
FillLEDCommand(pLED->pGreenLED->boardAddr, pLED->pGreenLED->LEDIndex, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[10]);
|
||||
|
||||
FillLEDCommand(pLED->pBlueLED->boardAddr, pLED->pBlueLED->LEDIndex, kPRLEDRegisterTypeFadeColor, fadeColor & 0xFF, &data[12]);
|
||||
FillLEDCommand(pLED->pBlueLED->boardAddr, pLED->pBlueLED->LEDIndex, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[14]);
|
||||
FillLEDCommand(pLED->pBlueLED->boardAddr, pLED->pBlueLED->LEDIndex, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[16]);
|
||||
|
||||
return PRWriteData(handle, 3, 0xc00, 18, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user