mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added PD-LED board functions.
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. */
|
/** Read the JTAG status register for the command complete bit and JTAG pin states. */
|
||||||
PINPROC_API PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
|
PINPROC_API PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status);
|
||||||
|
|
||||||
/** @} */ // End of DMD
|
/** @} */ // End of JTAG
|
||||||
|
|
||||||
|
// PD-LED
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup pdled PD-LED Control
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
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 on a given PRLED. */
|
||||||
|
PINPROC_API PRResult PRLEDFadeColor(PRHandle handle, PRLED * pLED, uint8_t fadeColor);
|
||||||
|
/** Sets the fade color and rate on a given PRLED. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on the same PD-LED board. */
|
||||||
|
PINPROC_API PRResult PRLEDFade(PRHandle handle, PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate);
|
||||||
|
|
||||||
|
/** Sets the fade rate on a given board. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on the same PD-LED board. */
|
||||||
|
PINPROC_API PRResult PRLEDFadeRate(PRHandle handle, uint8_t boardAddr, 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. Note: The rate will apply to any future PRLEDFadeColor or PRLEDRGBFadeColor calls on any of the referenced PD-LED boards. */
|
||||||
|
PINPROC_API PRResult PRLEDRGBFade(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate);
|
||||||
|
/** Sets the fade color on a given PRLEDRGB. */
|
||||||
|
PINPROC_API PRResult PRLEDRGBFadeColor(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor);
|
||||||
|
|
||||||
|
|
||||||
|
/** @} */ // End of PD-LED
|
||||||
|
|
||||||
|
|
||||||
/** @cond */
|
/** @cond */
|
||||||
PINPROC_EXTERN_C_END
|
PINPROC_EXTERN_C_END
|
||||||
|
|||||||
100
src/PRDevice.cpp
100
src/PRDevice.cpp
@@ -1344,3 +1344,103 @@ int PRDevice::GetVersionInfo(uint16_t *verPtr, uint16_t *revPtr, uint16_t *combi
|
|||||||
*combinedPtr = combinedVersionRevision;
|
*combinedPtr = combinedVersionRevision;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDColor(PRLED * pLED, uint8_t color)
|
||||||
|
{
|
||||||
|
uint32_t data[2];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->LEDIndex, data);
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeColor, color, &data[1]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 2, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDFade(PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
uint32_t data[4];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, data);
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[1]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->LEDIndex, &data[2]);
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeFadeColor, fadeColor, &data[3]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 4, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDFadeColor(PRLED * pLED, uint8_t fadeColor)
|
||||||
|
{
|
||||||
|
uint32_t data[2];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->LEDIndex, data);
|
||||||
|
FillLEDWriteCommand(pLED->boardAddr, kPRLEDRegisterTypeFadeColor, fadeColor, &data[1]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 2, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDFadeRate(uint8_t boardAddr, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
uint32_t data[2];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(boardAddr, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, data);
|
||||||
|
FillLEDWriteCommand(boardAddr, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[1]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 2, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDRGBColor(PRLEDRGB * pLED, uint32_t color)
|
||||||
|
{
|
||||||
|
uint32_t data[6];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pRedLED->LEDIndex, data);
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeColor, (color >> 16) & 0xFF, &data[1]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pGreenLED->LEDIndex, &data[2]);
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeColor, (color >> 8) & 0xFF, &data[3]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pBlueLED->LEDIndex, &data[4]);
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeColor, color & 0xFF, &data[5]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 6, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDRGBFade(PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
uint32_t data[12];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, data);
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[1]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pRedLED->LEDIndex, &data[2]);
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeFadeColor, (fadeColor >> 16) & 0xFF, &data[3]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[4]);
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[5]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pGreenLED->LEDIndex, &data[6]);
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeFadeColor, (fadeColor >> 8) & 0xFF, &data[7]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeFadeRateLow, fadeRate & 0xFF, &data[8]);
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeFadeRateHigh, (fadeRate >> 8) & 0xFF, &data[9]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pBlueLED->LEDIndex, &data[10]);
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeFadeColor, fadeColor & 0xFF, &data[11]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 12, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRDevice::PRLEDRGBFadeColor(PRLEDRGB * pLED, uint32_t fadeColor)
|
||||||
|
{
|
||||||
|
uint32_t data[6];
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pRedLED->LEDIndex, data);
|
||||||
|
FillLEDWriteCommand(pLED->pRedLED->boardAddr, kPRLEDRegisterTypeFadeColor, (fadeColor >> 16) & 0xFF, &data[1]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pGreenLED->LEDIndex, &data[2]);
|
||||||
|
FillLEDWriteCommand(pLED->pGreenLED->boardAddr, kPRLEDRegisterTypeFadeColor, (fadeColor >> 8) & 0xFF, &data[3]);
|
||||||
|
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeLEDIndex, pLED->pBlueLED->LEDIndex, &data[4]);
|
||||||
|
FillLEDWriteCommand(pLED->pBlueLED->boardAddr, kPRLEDRegisterTypeFadeColor, fadeColor & 0xFF, &data[5]);
|
||||||
|
|
||||||
|
return WriteDataRaw(3, 0xc00, 6, data);
|
||||||
|
}
|
||||||
|
|||||||
@@ -86,6 +86,13 @@ public:
|
|||||||
PRResult PRJTAGReadTDIMemory(uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData);
|
PRResult PRJTAGReadTDIMemory(uint16_t tableOffset, uint16_t numWords, uint32_t * tdiData);
|
||||||
PRResult PRJTAGGetStatus(PRJTAGStatus * status);
|
PRResult PRJTAGGetStatus(PRJTAGStatus * status);
|
||||||
|
|
||||||
|
PRResult PRLEDColor(PRLED * pLED, uint8_t color);
|
||||||
|
PRResult PRLEDFade(PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate);
|
||||||
|
PRResult PRLEDFadeColor(PRLED * pLED, uint8_t fadeColor);
|
||||||
|
PRResult PRLEDFadeRate(uint8_t boardAddr, uint16_t fadeRate);
|
||||||
|
PRResult PRLEDRGBColor(PRLEDRGB * pLED, uint32_t color);
|
||||||
|
PRResult PRLEDRGBFade(PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate);
|
||||||
|
PRResult PRLEDRGBFadeColor(PRLEDRGB * pLED, uint32_t fadeColor);
|
||||||
|
|
||||||
int GetVersionInfo(uint16_t *verPtr, uint16_t *revPtr, uint16_t *combinedPtr);
|
int GetVersionInfo(uint16_t *verPtr, uint16_t *revPtr, uint16_t *combinedPtr);
|
||||||
|
|
||||||
|
|||||||
@@ -344,6 +344,13 @@ int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t
|
|||||||
return kPRSuccess;
|
return kPRSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FillLEDWriteCommand(uint8_t boardAddr, PRLEDRegisterType reg, uint8_t value, uint32_t * pData)
|
||||||
|
{
|
||||||
|
pData[0] = (0x1 << 24) | (boardAddr << 16) | (reg << 8) | value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is where all FTDI driver-specific code should go.
|
* This is where all FTDI driver-specific code should go.
|
||||||
* As we add support for other drivers (such as D2xx on Windows), we will add more implementations of the PRHardware*() functions here.
|
* As we add support for other drivers (such as D2xx on Windows), we will add more implementations of the PRHardware*() functions here.
|
||||||
|
|||||||
@@ -254,6 +254,14 @@ const uint32_t P_ROC_DMD_RCLK_LOW_CYCLES_SHIFT = 24;
|
|||||||
|
|
||||||
const uint32_t P_ROC_DMD_DOT_TABLE_BASE_ADDR = 0x1000;
|
const uint32_t P_ROC_DMD_DOT_TABLE_BASE_ADDR = 0x1000;
|
||||||
|
|
||||||
|
typedef enum PRLEDRegisterType {
|
||||||
|
kPRLEDRegisterTypeLEDIndex = 0,
|
||||||
|
kPRLEDRegisterTypeColor = 1,
|
||||||
|
kPRLEDRegisterTypeFadeColor = 2,
|
||||||
|
kPRLEDRegisterTypeFadeRateLow = 3,
|
||||||
|
kPRLEDRegisterTypeFadeRateHigh = 4
|
||||||
|
} PRPDLEDRegisterType;
|
||||||
|
|
||||||
typedef struct PRSwitchRuleInternal {
|
typedef struct PRSwitchRuleInternal {
|
||||||
uint8_t switchNum; /**< Number of the physical switch, or for linked driver changes the virtual switch number (224 and up). */
|
uint8_t switchNum; /**< Number of the physical switch, or for linked driver changes the virtual switch number (224 and up). */
|
||||||
PREventType eventType; /**< The event type that this rule generates. Determines closed/open, debounced/non-debounced. */
|
PREventType eventType; /**< The event type that this rule generates. Determines closed/open, debounced/non-debounced. */
|
||||||
@@ -291,6 +299,8 @@ int32_t CreateJTAGLatchOutputsBurst ( uint32_t * burst, PRJTAGOutputs *jtagOutpu
|
|||||||
int32_t CreateJTAGForceOutputsBurst ( uint32_t * burst, PRJTAGOutputs *jtagOutputs);
|
int32_t CreateJTAGForceOutputsBurst ( uint32_t * burst, PRJTAGOutputs *jtagOutputs);
|
||||||
int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t dataBlockComplete);
|
int32_t CreateJTAGShiftTDODataBurst ( uint32_t * burst, uint16_t numBits, bool_t dataBlockComplete);
|
||||||
|
|
||||||
|
void FillLEDWriteCommand(uint8_t boardAddr, PRLEDRegisterType reg, uint8_t value, uint32_t * pData);
|
||||||
|
|
||||||
PRResult PRHardwareOpen();
|
PRResult PRHardwareOpen();
|
||||||
void PRHardwareClose();
|
void PRHardwareClose();
|
||||||
int PRHardwareRead(uint8_t *buffer, int maxBytes);
|
int PRHardwareRead(uint8_t *buffer, int maxBytes);
|
||||||
|
|||||||
@@ -567,3 +567,38 @@ PRResult PRJTAGGetStatus(PRHandle handle, PRJTAGStatus * status)
|
|||||||
{
|
{
|
||||||
return handleAsDevice->PRJTAGGetStatus(status);
|
return handleAsDevice->PRJTAGGetStatus(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDColor(PRHandle handle, PRLED * pLED, uint8_t color)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDColor(pLED, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDFade(PRHandle handle, PRLED * pLED, uint8_t fadeColor, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDFade(pLED, fadeColor, fadeRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDFadeColor(PRHandle handle, PRLED * pLED, uint8_t fadeColor)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDFadeColor(pLED, fadeColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDFadeRate(PRHandle handle, uint8_t boardAddr, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDFadeRate(boardAddr, fadeRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDRGBColor(PRHandle handle, PRLEDRGB * pLED, uint32_t color)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDRGBColor(pLED, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDRGBFade(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor, uint16_t fadeRate)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDRGBFade(pLED, fadeColor, fadeRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
PRResult PRLEDRGBFadeColor(PRHandle handle, PRLEDRGB * pLED, uint32_t fadeColor)
|
||||||
|
{
|
||||||
|
return handleAsDevice->PRLEDRGBFadeColor(pLED, fadeColor);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user