mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-04 05:13:51 -04:00
Update the Red Suite LPC1768 project and source to use the latest version of the tools.
This commit is contained in:
parent
19cdcbd681
commit
1677ec5c60
8 changed files with 190 additions and 169 deletions
|
@ -62,9 +62,9 @@ static TFnFrameHandler *_pfnFrameHandler = NULL;
|
|||
static void Wait4DevInt(unsigned long dwIntr)
|
||||
{
|
||||
// wait for specific interrupt
|
||||
while ((USB->USBDevIntSt & dwIntr) != dwIntr);
|
||||
while ((LPC_USB->USBDevIntSt & dwIntr) != dwIntr);
|
||||
// clear the interrupt bits
|
||||
USB->USBDevIntClr = dwIntr;
|
||||
LPC_USB->USBDevIntClr = dwIntr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,9 +76,9 @@ static void Wait4DevInt(unsigned long dwIntr)
|
|||
static void USBHwCmd(unsigned char bCmd)
|
||||
{
|
||||
// clear CDFULL/CCEMTY
|
||||
USB->USBDevIntClr = CDFULL | CCEMTY;
|
||||
LPC_USB->USBDevIntClr = CDFULL | CCEMTY;
|
||||
// write command code
|
||||
USB->USBCmdCode = 0x00000500 | (bCmd << 16);
|
||||
LPC_USB->USBCmdCode = 0x00000500 | (bCmd << 16);
|
||||
Wait4DevInt(CCEMTY);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ static void USBHwCmdWrite(unsigned char bCmd, unsigned short bData)
|
|||
USBHwCmd(bCmd);
|
||||
|
||||
// write command data
|
||||
USB->USBCmdCode = 0x00000100 | (bData << 16);
|
||||
LPC_USB->USBCmdCode = 0x00000100 | (bData << 16);
|
||||
Wait4DevInt(CCEMTY);
|
||||
}
|
||||
|
||||
|
@ -113,9 +113,9 @@ static unsigned char USBHwCmdRead(unsigned char bCmd)
|
|||
USBHwCmd(bCmd);
|
||||
|
||||
// get data
|
||||
USB->USBCmdCode = 0x00000200 | (bCmd << 16);
|
||||
LPC_USB->USBCmdCode = 0x00000200 | (bCmd << 16);
|
||||
Wait4DevInt(CDFULL);
|
||||
return USB->USBCmdData;
|
||||
return LPC_USB->USBCmdData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,9 +132,9 @@ static unsigned char USBHwCmdRead(unsigned char bCmd)
|
|||
*/
|
||||
static void USBHwEPRealize(int idx, unsigned short wMaxPSize)
|
||||
{
|
||||
USB->USBReEP |= (1 << idx);
|
||||
USB->USBEpInd = idx;
|
||||
USB->USBMaxPSize = wMaxPSize;
|
||||
LPC_USB->USBReEP |= (1 << idx);
|
||||
LPC_USB->USBEpInd = idx;
|
||||
LPC_USB->USBMaxPSize = wMaxPSize;
|
||||
Wait4DevInt(EP_RLZED);
|
||||
}
|
||||
|
||||
|
@ -189,8 +189,8 @@ void USBHwRegisterEPIntHandler(unsigned char bEP, TFnEPIntHandler *pfnHandler)
|
|||
_apfnEPIntHandlers[idx / 2] = pfnHandler;
|
||||
|
||||
/* enable EP interrupt */
|
||||
USB->USBEpIntEn |= (1 << idx);
|
||||
USB->USBDevIntEn |= EP_SLOW;
|
||||
LPC_USB->USBEpIntEn |= (1 << idx);
|
||||
LPC_USB->USBDevIntEn |= EP_SLOW;
|
||||
|
||||
DBG("Registered handler for EP 0x%x\n", bEP);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ void USBHwRegisterDevIntHandler(TFnDevIntHandler *pfnHandler)
|
|||
_pfnDevIntHandler = pfnHandler;
|
||||
|
||||
// enable device interrupt
|
||||
USB->USBDevIntEn |= DEV_STAT;
|
||||
LPC_USB->USBDevIntEn |= DEV_STAT;
|
||||
|
||||
DBG("Registered handler for device status\n");
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void USBHwRegisterFrameHandler(TFnFrameHandler *pfnHandler)
|
|||
_pfnFrameHandler = pfnHandler;
|
||||
|
||||
// enable device interrupt
|
||||
USB->USBDevIntEn |= FRAME;
|
||||
LPC_USB->USBDevIntEn |= FRAME;
|
||||
|
||||
DBG("Registered handler for frame\n");
|
||||
}
|
||||
|
@ -313,14 +313,14 @@ int USBHwEPWrite(unsigned char bEP, unsigned char *pbBuf, int iLen)
|
|||
idx = EP2IDX(bEP);
|
||||
|
||||
// set write enable for specific endpoint
|
||||
USB->USBCtrl = WR_EN | ((bEP & 0xF) << 2);
|
||||
LPC_USB->USBCtrl = WR_EN | ((bEP & 0xF) << 2);
|
||||
|
||||
// set packet length
|
||||
USB->USBTxPLen = iLen;
|
||||
LPC_USB->USBTxPLen = iLen;
|
||||
|
||||
// write data
|
||||
while (USB->USBCtrl & WR_EN) {
|
||||
USB->USBTxData = (pbBuf[3] << 24) | (pbBuf[2] << 16) | (pbBuf[1] << 8) | pbBuf[0];
|
||||
while (LPC_USB->USBCtrl & WR_EN) {
|
||||
LPC_USB->USBTxData = (pbBuf[3] << 24) | (pbBuf[2] << 16) | (pbBuf[1] << 8) | pbBuf[0];
|
||||
pbBuf += 4;
|
||||
}
|
||||
|
||||
|
@ -350,11 +350,11 @@ int USBHwEPRead(unsigned char bEP, unsigned char *pbBuf, int iMaxLen)
|
|||
idx = EP2IDX(bEP);
|
||||
|
||||
// set read enable bit for specific endpoint
|
||||
USB->USBCtrl = RD_EN | ((bEP & 0xF) << 2);
|
||||
LPC_USB->USBCtrl = RD_EN | ((bEP & 0xF) << 2);
|
||||
|
||||
// wait for PKT_RDY
|
||||
do {
|
||||
dwLen = USB->USBRxPLen;
|
||||
dwLen = LPC_USB->USBRxPLen;
|
||||
} while ((dwLen & PKT_RDY) == 0);
|
||||
|
||||
// packet valid?
|
||||
|
@ -369,7 +369,7 @@ int USBHwEPRead(unsigned char bEP, unsigned char *pbBuf, int iMaxLen)
|
|||
dwData = 0;
|
||||
for (i = 0; i < dwLen; i++) {
|
||||
if ((i % 4) == 0) {
|
||||
dwData = USB->USBRxData;
|
||||
dwData = LPC_USB->USBRxData;
|
||||
}
|
||||
if ((pbBuf != NULL) && (i < iMaxLen)) {
|
||||
pbBuf[i] = dwData & 0xFF;
|
||||
|
@ -378,7 +378,7 @@ int USBHwEPRead(unsigned char bEP, unsigned char *pbBuf, int iMaxLen)
|
|||
}
|
||||
|
||||
// make sure RD_EN is clear
|
||||
USB->USBCtrl = 0;
|
||||
LPC_USB->USBCtrl = 0;
|
||||
|
||||
// select endpoint and clear buffer
|
||||
USBHwCmd(CMD_EP_SELECT | idx);
|
||||
|
@ -419,12 +419,12 @@ void USBHwISR(void)
|
|||
unsigned short wFrame;
|
||||
|
||||
// handle device interrupts
|
||||
dwStatus = USB->USBDevIntSt;
|
||||
dwStatus = LPC_USB->USBDevIntSt;
|
||||
|
||||
// frame interrupt
|
||||
if (dwStatus & FRAME) {
|
||||
// clear int
|
||||
USB->USBDevIntClr = FRAME;
|
||||
LPC_USB->USBDevIntClr = FRAME;
|
||||
// call handler
|
||||
if (_pfnFrameHandler != NULL) {
|
||||
wFrame = USBHwCmdRead(CMD_DEV_READ_CUR_FRAME_NR);
|
||||
|
@ -438,7 +438,7 @@ void USBHwISR(void)
|
|||
This prevents corrupted device status reads, see
|
||||
LPC2148 User manual revision 2, 25 july 2006.
|
||||
*/
|
||||
USB->USBDevIntClr = DEV_STAT;
|
||||
LPC_USB->USBDevIntClr = DEV_STAT;
|
||||
bDevStat = USBHwCmdRead(CMD_DEV_STATUS);
|
||||
if (bDevStat & (CON_CH | SUS_CH | RST)) {
|
||||
// convert device status into something HW independent
|
||||
|
@ -455,15 +455,15 @@ void USBHwISR(void)
|
|||
// endpoint interrupt
|
||||
if (dwStatus & EP_SLOW) {
|
||||
// clear EP_SLOW
|
||||
USB->USBDevIntClr = EP_SLOW;
|
||||
LPC_USB->USBDevIntClr = EP_SLOW;
|
||||
// check all endpoints
|
||||
for (i = 0; i < 32; i++) {
|
||||
dwIntBit = (1 << i);
|
||||
if (USB->USBEpIntSt & dwIntBit) {
|
||||
if (LPC_USB->USBEpIntSt & dwIntBit) {
|
||||
// clear int (and retrieve status)
|
||||
USB->USBEpIntClr = dwIntBit;
|
||||
LPC_USB->USBEpIntClr = dwIntBit;
|
||||
Wait4DevInt(CDFULL);
|
||||
bEPStat = USB->USBCmdData;
|
||||
bEPStat = LPC_USB->USBCmdData;
|
||||
// convert EP pipe stat into something HW independent
|
||||
bStat = ((bEPStat & EPSTAT_FE) ? EP_STATUS_DATA : 0) |
|
||||
((bEPStat & EPSTAT_ST) ? EP_STATUS_STALLED : 0) |
|
||||
|
@ -490,33 +490,33 @@ void USBHwISR(void)
|
|||
BOOL USBHwInit(void)
|
||||
{
|
||||
// P2.9 -> USB_CONNECT
|
||||
PINCON->PINSEL4 &= ~0x000C0000;
|
||||
PINCON->PINSEL4 |= 0x00040000;
|
||||
LPC_PINCON->PINSEL4 &= ~0x000C0000;
|
||||
LPC_PINCON->PINSEL4 |= 0x00040000;
|
||||
|
||||
// P1.18 -> USB_UP_LED
|
||||
// P1.30 -> VBUS
|
||||
PINCON->PINSEL3 &= ~0x30000030;
|
||||
PINCON->PINSEL3 |= 0x20000010;
|
||||
LPC_PINCON->PINSEL3 &= ~0x30000030;
|
||||
LPC_PINCON->PINSEL3 |= 0x20000010;
|
||||
|
||||
// P0.29 -> USB_D+
|
||||
// P0.30 -> USB_D-
|
||||
PINCON->PINSEL1 &= ~0x3C000000;
|
||||
PINCON->PINSEL1 |= 0x14000000;
|
||||
LPC_PINCON->PINSEL1 &= ~0x3C000000;
|
||||
LPC_PINCON->PINSEL1 |= 0x14000000;
|
||||
|
||||
// enable PUSB
|
||||
SC->PCONP |= (1 << 31);
|
||||
LPC_SC->PCONP |= (1 << 31);
|
||||
|
||||
USB->OTGClkCtrl = 0x12; /* Dev clock, AHB clock enable */
|
||||
while ((USB->OTGClkSt & 0x12) != 0x12);
|
||||
LPC_USB->OTGClkCtrl = 0x12; /* Dev clock, AHB clock enable */
|
||||
while ((LPC_USB->OTGClkSt & 0x12) != 0x12);
|
||||
|
||||
// disable/clear all interrupts for now
|
||||
USB->USBDevIntEn = 0;
|
||||
USB->USBDevIntClr = 0xFFFFFFFF;
|
||||
USB->USBDevIntPri = 0;
|
||||
LPC_USB->USBDevIntEn = 0;
|
||||
LPC_USB->USBDevIntClr = 0xFFFFFFFF;
|
||||
LPC_USB->USBDevIntPri = 0;
|
||||
|
||||
USB->USBEpIntEn = 0;
|
||||
USB->USBEpIntClr = 0xFFFFFFFF;
|
||||
USB->USBEpIntPri = 0;
|
||||
LPC_USB->USBEpIntEn = 0;
|
||||
LPC_USB->USBEpIntClr = 0xFFFFFFFF;
|
||||
LPC_USB->USBEpIntPri = 0;
|
||||
|
||||
// by default, only ACKs generate interrupts
|
||||
USBHwNakIntEnable(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue