diff options
-rw-r--r-- | openpcd/firmware/src/dbgu.c | 4 | ||||
-rw-r--r-- | openpcd/firmware/src/dbgu.h | 2 | ||||
-rw-r--r-- | openpcd/firmware/src/main.c | 8 | ||||
-rw-r--r-- | openpcd/firmware/src/pcd_enumerate.c | 15 | ||||
-rw-r--r-- | openpcd/firmware/src/rc632.c | 18 | ||||
-rw-r--r-- | openpcd/firmware/src/req_ctx.c | 2 |
6 files changed, 26 insertions, 23 deletions
diff --git a/openpcd/firmware/src/dbgu.c b/openpcd/firmware/src/dbgu.c index 81d83b6..0de2bd3 100644 --- a/openpcd/firmware/src/dbgu.c +++ b/openpcd/firmware/src/dbgu.c @@ -87,12 +87,12 @@ static void DBGU_irq_handler(void) break; case '5': - DEBUGP("Reading RC632 Reg RxWait: 0x%02x\n\r", + DEBUGPCR("Reading RC632 Reg RxWait: 0x%02xr", rc632_reg_read(RC632_REG_RX_WAIT)); break; case '6': - DEBUGP("Writing RC632 Reg RxWait: 0x%02x\n\r", + DEBUGPCR("Writing RC632 Reg RxWait: 0x%02x", rc632_reg_write(RC632_REG_RX_WAIT, 0x55)); break; case '7': diff --git a/openpcd/firmware/src/dbgu.h b/openpcd/firmware/src/dbgu.h index c38fd63..1731e10 100644 --- a/openpcd/firmware/src/dbgu.h +++ b/openpcd/firmware/src/dbgu.h @@ -32,6 +32,8 @@ void AT91F_DBGU_scanf(char * type,unsigned int * val); #ifdef DEBUG
extern void debugp(const char *format, ...);
#define DEBUGP(x, args ...) debugp(x, ## args)
+#define DEBUGPCR(x, args ...) DEBUGP(x "\r\n", ## args)
+#define DEBUGPCRF(x, args ...) DEBUGPCR("%s(%d): " x, __FUNCTION__, __LINE__, ## args)
#else
#define DEBUGP(x, args ...) do {} while(0)
#endif
diff --git a/openpcd/firmware/src/main.c b/openpcd/firmware/src/main.c index 552638d..0860293 100644 --- a/openpcd/firmware/src/main.c +++ b/openpcd/firmware/src/main.c @@ -104,7 +104,9 @@ static int usb_in(struct req_ctx *rctx) default: return -EINVAL; } - //AT91F_UDP_Write(0, &rctx->tx.data[0], rctx->tx.tot_len); + DEBUGPCRF("calling UDP_Write"); + AT91F_UDP_Write(0, &rctx->tx.data[0], rctx->tx.tot_len); + DEBUGPCRF("usb_in: returning to main"); } #define DEBUG_TOGGLE_LED @@ -123,8 +125,6 @@ int main(void) rc632_init(); - //printf("test 0x%02x\n\r", 123); - // Enable User Reset and set its minimal assertion to 960 us AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4 << 8) | (unsigned int)(0xA5 << 24); @@ -160,7 +160,7 @@ int main(void) for (rctx = req_ctx_find_busy(); rctx; rctx = req_ctx_find_busy()) { - DEBUGP("found used ctx %u: len=%u\r\n", + DEBUGPCRF("found used ctx %u: len=%u", req_ctx_num(rctx), rctx->rx.tot_len); usb_in(rctx); req_ctx_put(rctx); diff --git a/openpcd/firmware/src/pcd_enumerate.c b/openpcd/firmware/src/pcd_enumerate.c index 31c9398..36dedfb 100644 --- a/openpcd/firmware/src/pcd_enumerate.c +++ b/openpcd/firmware/src/pcd_enumerate.c @@ -311,6 +311,8 @@ u_int32_t AT91F_UDP_Write(u_int8_t irq, const char *pData, u_int32_t length) u_int32_t cpt = 0; u_int8_t ep; + DEBUGPCRF("enter\n"); + if (irq) ep = 3; else @@ -321,29 +323,38 @@ u_int32_t AT91F_UDP_Write(u_int8_t irq, const char *pData, u_int32_t length) length -= cpt; while (cpt--) pUdp->UDP_FDR[ep] = *pData++; + DEBUGPCRF("sending first packet"); pUdp->UDP_CSR[ep] |= AT91C_UDP_TXPKTRDY; while (length) { + DEBUGPCRF("sending further packet"); // Fill the second bank cpt = MIN(length, 64); length -= cpt; while (cpt--) pUdp->UDP_FDR[ep] = *pData++; + DEBUGPCRF("waiting for end of further packet"); // Wait for the the first bank to be sent while (!(pUdp->UDP_CSR[ep] & AT91C_UDP_TXCOMP)) - if (!AT91F_UDP_IsConfigured()) + if (!AT91F_UDP_IsConfigured()) { + DEBUGPCRF("return(!configured)"); return length; + } pUdp->UDP_CSR[ep] &= ~(AT91C_UDP_TXCOMP); while (pUdp->UDP_CSR[ep] & AT91C_UDP_TXCOMP) ; pUdp->UDP_CSR[ep] |= AT91C_UDP_TXPKTRDY; } // Wait for the end of transfer + DEBUGPCRF("waiting for end of transfer"); while (!(pUdp->UDP_CSR[ep] & AT91C_UDP_TXCOMP)) - if (!AT91F_UDP_IsConfigured()) + if (!AT91F_UDP_IsConfigured()) { + DEBUGPCRF("return(!configured)"); return length; + } pUdp->UDP_CSR[ep] &= ~(AT91C_UDP_TXCOMP); while (pUdp->UDP_CSR[ep] & AT91C_UDP_TXCOMP) ; + DEBUGPCRF("return(normal, len=%u)\n", length); return length; } diff --git a/openpcd/firmware/src/rc632.c b/openpcd/firmware/src/rc632.c index 85fbcd2..1f94dd0 100644 --- a/openpcd/firmware/src/rc632.c +++ b/openpcd/firmware/src/rc632.c @@ -38,7 +38,7 @@ int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len, u_int16_t rx_len_max = 0; u_int16_t rx_cnt = 0; - DEBUGP("%s enter(tx_len=%u)\r\n", __FUNCTION__, tx_len); + DEBUGPCRF("enter(tx_len=%u)", tx_len); if (rx_len) { rx_len_max = *rx_len; @@ -68,7 +68,7 @@ int spi_transceive(const u_int8_t *tx_data, u_int16_t tx_len, break; } AT91F_SPI_Disable(pSPI); - DEBUGP("%s leave(%02x %02x)\r\n", __FUNCTION__, rx_data[0], rx_data[1]); + DEBUGPCRF("leave(%02x %02x)", rx_data[0], rx_data[1]); return 0; } @@ -210,34 +210,25 @@ void rc632_init(void) { //fifo_init(&rc632.fifo, 256, NULL, &rc632); - DEBUGP("rc632_pmc\r\n"); + DEBUGPCRF("entering"); AT91F_SPI_CfgPMC(); - DEBUGP("rc632_pio\r\n"); AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, AT91C_PA11_NPCS0|AT91C_PA12_MISO| AT91C_PA13_MOSI |AT91C_PA14_SPCK, 0); - DEBUGP("rc632_en_spi\r\n"); //AT91F_SPI_Enable(pSPI); - DEBUGP("rc632_cfg_it_spi\r\n"); AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SPI, AT91C_AIC_PRIOR_HIGHEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, &spi_irq); - DEBUGP("rc632_en_it_spi\r\n"); AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SPI); - - DEBUGP("rc632_spi_en_it\r\n"); - //AT91F_SPI_EnableIt(pSPI, AT91C_SPI_MODF|AT91C_SPI_OVRES|AT91C_SPI_RDRF|AT91C_SPI_TDRE); - DEBUGP("rc632_spi_cfg_mode\r\n"); + AT91F_SPI_EnableIt(pSPI, AT91C_SPI_MODF|AT91C_SPI_OVRES|AT91C_SPI_RDRF|AT91C_SPI_TDRE); AT91F_SPI_CfgMode(pSPI, AT91C_SPI_MSTR|AT91C_SPI_PS_FIXED); /* CPOL = 0, NCPHA = 1, CSAAT = 0, BITS = 0000, SCBR = 10 (4.8MHz), * DLYBS = 0, DLYBCT = 0 */ - DEBUGP("rc632_spi_cfg_cs\r\n"); //AT91F_SPI_CfgCs(pSPI, 0, AT91C_SPI_BITS_8|AT91C_SPI_NCPHA|(10<<8)); AT91F_SPI_CfgCs(pSPI, 0, AT91C_SPI_BITS_8|AT91C_SPI_NCPHA|(0xff<<8)); - //DEBUGP("rc632_spi_reset\r\n"); //AT91F_SPI_Reset(pSPI); /* Register rc632_irq */ @@ -247,7 +238,6 @@ void rc632_init(void) AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPCD_RC632_RESET); - DEBUGP("rc632_reset\r\n"); rc632_reset(); }; diff --git a/openpcd/firmware/src/req_ctx.c b/openpcd/firmware/src/req_ctx.c index 41298e6..025bf5e 100644 --- a/openpcd/firmware/src/req_ctx.c +++ b/openpcd/firmware/src/req_ctx.c @@ -42,7 +42,7 @@ void req_ctx_put(struct req_ctx *ctx) { int offset = req_ctx_num(ctx); if (offset > NUM_REQ_CTX) - DEBUGP("Error in offset calculation req_ctx_put\n"); + DEBUGPCR("Error in offset calculation req_ctx_put"); req_ctx_busy &= ~(1 << offset); } |