void cliInit() { #if defined CFG_BSP_INTERFACE && defined CFG_BSP_PRINTF_UART // Check if UART is already initialised uart_pcb_t *pcb = uartGetPCB(); if (!pcb->initialised) { uartInit(CFG_BSP_UART_BAUDRATE); } #endif #if CFG_BSP_INTERFACE_ENABLEIRQ != 0 // Set IRQ pin as output LPC_GPIO->DIR[CFG_BSP_INTERFACE_IRQPORT] |= (1 << CFG_BSP_INTERFACE_IRQPIN); LPC_GPIO->SET[CFG_BSP_INTERFACE_IRQPORT] = (1 << CFG_BSP_INTERFACE_IRQPIN); #endif // init the cli_buffer ptr cli_buffer_ptr = cli_buffer; // Show the menu cliMenu(); // Set the IRQ pin low by default #if CFG_BSP_INTERFACE_ENABLEIRQ != 0 LPC_GPIO->CLR[CFG_BSP_INTERFACE_IRQPORT] = (1 << CFG_BSP_INTERFACE_IRQPIN); #endif }
void cmdInit() { #if defined CFG_INTERFACE && defined CFG_INTERFACE_UART // Check if UART is already initialised uart_pcb_t *pcb = uartGetPCB(); if (!pcb->initialised) { uartInit(CFG_UART_BAUDRATE); } #endif #if CFG_INTERFACE_ENABLEIRQ != 0 // Set IRQ pin as output gpioSetDir(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, gpioDirection_Output); gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 1); #endif // init the msg ptr msg_ptr = msg; // Show the menu cmdMenu(); // Set the IRQ pin low by default #if CFG_INTERFACE_ENABLEIRQ != 0 gpioSetValue(CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, 0); #endif }
void cmd_sysinfo(uint8_t argc, char **argv) { IAP_return_t iap_return; printf("%-25s : %d.%d MHz %s", "System Clock", CFG_CPU_CCLK / 1000000, CFG_CPU_CCLK % 1000000, CFG_PRINTF_NEWLINE); printf("%-25s : v%d.%d.%d %s", "Firmware", CFG_FIRMWARE_VERSION_MAJOR, CFG_FIRMWARE_VERSION_MINOR, CFG_FIRMWARE_VERSION_REVISION, CFG_PRINTF_NEWLINE); // 128-bit MCU Serial Number iap_return = iapReadSerialNumber(); if(iap_return.ReturnCode == 0) { printf("%-25s : %08X %08X %08X %08X %s", "Serial Number", iap_return.Result[0],iap_return.Result[1],iap_return.Result[2],iap_return.Result[3], CFG_PRINTF_NEWLINE); } // CLI and buffer Settings #ifdef CFG_INTERFACE printf("%-25s : %d bytes %s", "Max CLI Command", CFG_INTERFACE_MAXMSGSIZE, CFG_PRINTF_NEWLINE); #endif #ifdef CFG_PRINTF_UART uart_pcb_t *pcb = uartGetPCB(); printf("%-25s : %d %s", "UART Baud Rate", pcb->baudrate, CFG_PRINTF_NEWLINE); #endif // TFT LCD Settings (if CFG_TFTLCD enabled) #ifdef CFG_TFTLCD printf("%-25s : %d %s", "LCD Width", (int)lcdGetWidth(), CFG_PRINTF_NEWLINE); printf("%-25s : %d %s", "LCD Height", (int)lcdGetHeight(), CFG_PRINTF_NEWLINE); #endif // Wireless Settings (if CFG_CHIBI enabled) #ifdef CFG_CHIBI chb_pcb_t *pcb = chb_get_pcb(); printf("%-25s : %s %s", "Wireless", "AT86RF212", CFG_PRINTF_NEWLINE); printf("%-25s : 0x%04X %s", "802.15.4 PAN ID", CFG_CHIBI_PANID, CFG_PRINTF_NEWLINE); printf("%-25s : 0x%04X %s", "802.15.4 Node Address", pcb->src_addr, CFG_PRINTF_NEWLINE); printf("%-25s : %d %s", "802.15.4 Channel", CFG_CHIBI_CHANNEL, CFG_PRINTF_NEWLINE); #endif // System Uptime (based on systick timer) printf("%-25s : %u s %s", "System Uptime", (unsigned int)systickGetSecondsActive(), CFG_PRINTF_NEWLINE); // System Temperature (if LM75B Present) #ifdef CFG_LM75B int32_t temp = 0; lm75bGetTemperature(&temp); temp *= 125; printf("%-25s : %d.%d C %s", "Temperature", temp / 1000, temp % 1000, CFG_PRINTF_NEWLINE); #endif #ifdef CFG_SDCARD printf("%-25s : %s %s", "SD Card Present", gpioGetValue(CFG_SDCARD_CDPORT, CFG_SDCARD_CDPIN) ? "True" : "False", CFG_PRINTF_NEWLINE); #endif }
void cmdInit() { #ifdef CFG_INTERFACE_UART // Check if UART is already initialised uart_pcb_t *pcb = uartGetPCB(); if (!pcb->initialised) { uartInit(CFG_UART_BAUDRATE); } #endif // init the msg ptr msg_ptr = msg; // Show the menu cmdMenu(); }
void cmd_sysinfo(uint8_t argc, char **argv) { IAP_return_t iap_return; /* Note: Certain values are only reported if CFG_INTERFACE_LONGSYSINFO is set to 1 in projectconfig.h. These extra values are more useful for debugging than real-world use, so there's no point wasiting flash space storing the code for them */ printf("%-25s : %d.%d.%d %s", "Firmware", CFG_FIRMWARE_VERSION_MAJOR, CFG_FIRMWARE_VERSION_MINOR, CFG_FIRMWARE_VERSION_REVISION, CFG_PRINTF_NEWLINE); printf("%-25s : %d.%d MHz %s", "System Clock", CFG_CPU_CCLK / 1000000, CFG_CPU_CCLK % 1000000, CFG_PRINTF_NEWLINE); // System Uptime (based on systick timer) printf("%-25s : %u s %s", "System Uptime", (unsigned int)systickGetSecondsActive(), CFG_PRINTF_NEWLINE); // 128-bit MCU Serial Number iap_return = iapReadSerialNumber(); if(iap_return.ReturnCode == 0) { printf("%-25s : %08X %08X %08X %08X %s", "Serial Number", iap_return.Result[0],iap_return.Result[1],iap_return.Result[2],iap_return.Result[3], CFG_PRINTF_NEWLINE); } #if CFG_INTERFACE_LONGSYSINFO #ifdef CFG_USBCDC printf("%-25s : %d ms %s", "USB Init Timeout", CFG_USBCDC_INITTIMEOUT, CFG_PRINTF_NEWLINE); #endif #endif // CLI and buffer Settings #if CFG_INTERFACE_LONGSYSINFO printf("%-25s : %d bytes %s", "CLI Max Command Size", CFG_INTERFACE_MAXMSGSIZE, CFG_PRINTF_NEWLINE); printf("%-25s : %s %s", "CLI IRQ Enabled", CFG_INTERFACE_ENABLEIRQ ? "True" : "False", CFG_PRINTF_NEWLINE); #if CFG_INTERFACE_ENABLEIRQ printf("%-25s : %d.%d %s", "CLI IRQ Location", CFG_INTERFACE_IRQPORT, CFG_INTERFACE_IRQPIN, CFG_PRINTF_NEWLINE); #endif #endif #if CFG_INTERFACE_LONGSYSINFO #ifdef CFG_I2CEEPROM printf("%-25s : %d bytes %s", "EEPROM Size", CFG_I2CEEPROM_SIZE, CFG_PRINTF_NEWLINE); #endif #endif #ifdef CFG_SDCARD printf("%-25s : %s %s", "SD Card Present", gpioGetValue(CFG_SDCARD_CDPORT, CFG_SDCARD_CDPIN) ? "True" : "False", CFG_PRINTF_NEWLINE); #if CFG_INTERFACE_LONGSYSINFO printf("%-25s : %s %s", "FAT File System", CFG_SDCARD_READONLY ? "Read Only" : "Read/Write", CFG_PRINTF_NEWLINE); #endif #endif #ifdef CFG_PRINTF_UART uart_pcb_t *pcb = uartGetPCB(); printf("%-25s : %u %s", "UART Baud Rate", (unsigned int)(pcb->baudrate), CFG_PRINTF_NEWLINE); #endif // TFT LCD Settings (if CFG_TFTLCD enabled) #ifdef CFG_TFTLCD printf("%-25s : %d %s", "LCD Width", (int)lcdGetWidth(), CFG_PRINTF_NEWLINE); printf("%-25s : %d %s", "LCD Height", (int)lcdGetHeight(), CFG_PRINTF_NEWLINE); #if CFG_INTERFACE_LONGSYSINFO printf("%-25s : %04X %s", "LCD Controller ID", (unsigned short)lcdGetControllerID(), CFG_PRINTF_NEWLINE); printf("%-25s : %s %s", "LCD Small Fonts", CFG_TFTLCD_INCLUDESMALLFONTS == 1 ? "True" : "False", CFG_PRINTF_NEWLINE); printf("%-25s : %s %s", "LCD AA Fonts", CFG_TFTLCD_USEAAFONTS == 1 ? "True" : "False", CFG_PRINTF_NEWLINE); lcdProperties_t lcdprops = lcdGetProperties(); printf("%-25s : %s %s", "Touch Screen", lcdprops.touchscreen ? "True" : "False", CFG_PRINTF_NEWLINE); if (lcdprops.touchscreen) { printf("%-25s : %s %s", "Touch Screen Calibrated", eepromReadU8(CFG_EEPROM_TOUCHSCREEN_CALIBRATED) == 1 ? "True" : "False", CFG_PRINTF_NEWLINE); printf("%-25s : %d %s", "Touch Screen Threshold", CFG_TFTLCD_TS_DEFAULTTHRESHOLD, CFG_PRINTF_NEWLINE); } #endif #endif // Wireless Settings (if CFG_CHIBI enabled) #ifdef CFG_CHIBI chb_pcb_t *pcb = chb_get_pcb(); printf("%-25s : %s %s", "Wireless", "AT86RF212", CFG_PRINTF_NEWLINE); printf("%-25s : 0x%04X %s", "802.15.4 PAN ID", CFG_CHIBI_PANID, CFG_PRINTF_NEWLINE); printf("%-25s : 0x%04X %s", "802.15.4 Node Address", pcb->src_addr, CFG_PRINTF_NEWLINE); printf("%-25s : %d %s", "802.15.4 Channel", CFG_CHIBI_CHANNEL, CFG_PRINTF_NEWLINE); #endif // System Temperature (if LM75B Present) #ifdef CFG_LM75B int32_t temp = 0; lm75bGetTemperature(&temp); temp *= 125; printf("%-25s : %d.%d C %s", "Temperature", temp / 1000, temp % 1000, CFG_PRINTF_NEWLINE); #endif // ADC Averaging #if CFG_INTERFACE_LONGSYSINFO printf("%-25s : %s %s", "ADC Averaging", ADC_AVERAGING_ENABLE ? "True" : "False", CFG_PRINTF_NEWLINE); #if ADC_AVERAGING_ENABLE printf("%-25s : %d %s", "ADC Averaging Samples", ADC_AVERAGING_SAMPLES, CFG_PRINTF_NEWLINE); #endif #endif // Debug LED #if CFG_INTERFACE_LONGSYSINFO printf("%-25s : %d.%d %s", "LED Location", CFG_LED_PORT, CFG_LED_PIN, CFG_PRINTF_NEWLINE); #endif }
pn532_error_t pn532_bus_SendCommand(const byte_t * pbtData, const size_t szData) { pn532_pcb_t *pn532 = pn532GetPCB(); // Check if we're busy if (pn532->state == PN532_STATE_BUSY) { return PN532_ERROR_BUSY; } // Flag the stack as busy pn532->state = PN532_STATE_BUSY; // Every packet must start with "00 00 ff" byte_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; size_t szFrame = 0; // Build the frame pn532_bus_BuildFrame (abtFrame, &szFrame, pbtData, szData); // Keep track of the last command that was sent pn532->lastCommand = pbtData[0]; // Output the frame data for debugging if requested #ifdef PN532_DEBUGMODE PN532_DEBUG("Sending (%02d): ", szFrame); pn532PrintHex(abtFrame, szFrame); #endif // Send data to the PN532 uartSend (abtFrame, szFrame); // Wait for ACK byte_t abtRxBuf[6]; uart_pcb_t *uart = uartGetPCB(); delay(10); // FIXME: How long should we wait for ACK? if (uart->rxfifo.len < 6) { // Unable to read ACK #ifdef PN532_DEBUGMODE PN532_DEBUG ("Unable to read ACK%s", CFG_PRINTF_NEWLINE); #endif pn532->state = PN532_STATE_READY; return PN532_ERROR_NOACK; } // Read ACK ... this will also remove it from the buffer const byte_t abtAck[6] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 }; abtRxBuf[0] = uartRxBufferRead(); abtRxBuf[1] = uartRxBufferRead(); abtRxBuf[2] = uartRxBufferRead(); abtRxBuf[3] = uartRxBufferRead(); abtRxBuf[4] = uartRxBufferRead(); abtRxBuf[5] = uartRxBufferRead(); // Make sure the received ACK matches the prototype if (0 != (memcmp (abtRxBuf, abtAck, 6))) { #ifdef PN532_DEBUGMODE PN532_DEBUG ("Invalid ACK: "); pn532PrintHex(abtRxBuf, 6); PN532_DEBUG("%s", CFG_PRINTF_NEWLINE); #endif pn532->state = PN532_STATE_READY; return PN532_ERROR_INVALIDACK; } pn532->state = PN532_STATE_READY; return PN532_ERROR_NONE; }