本文整理汇总了C++中UARTprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ UARTprintf函数的具体用法?C++ UARTprintf怎么用?C++ UARTprintf使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UARTprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cmd_cat
//
// Cmd_cat - This function implements the "cat" command. It reads the contents
// of a file and prints it to the console. This should only be used
// on text files. If it is used on a binary file, then a bunch of
// garbage is likely to printed on the console.
//
int
Cmd_cat(int argc, char *argv[])
{
FRESULT fresult;
unsigned short usBytesRead;
//
// First, check to make sure that the current path (CWD), plus
// the file name, plus a separator and trailing null, will all
// fit in the temporary buffer that will be used to hold the
// file name. The file name must be fully specified, with path,
// to FatFs.
//
if(strlen(g_cCwdBuf) + strlen(argv[1]) + 1 + 1 > sizeof(g_cTmpBuf))
{
UARTprintf("Resulting path name is too long\n");
return(0);
}
//
// Copy the current path to the temporary buffer so it can be manipulated.
//
strcpy(g_cTmpBuf, g_cCwdBuf);
//
// If not already at the root level, then append a separator.
//
if(strcmp("/", g_cCwdBuf))
{
strcat(g_cTmpBuf, "/");
}
//
// Now finally, append the file name to result in a fully specified file.
//
strcat(g_cTmpBuf, argv[1]);
//
// Open the file for reading.
//
fresult = f_open(&g_sFileObject, g_cTmpBuf, FA_READ);
//
// If there was some problem opening the file, then return
// an error.
//
if(fresult != FR_OK)
{
return(fresult);
}
//
// Enter a loop to repeatedly read data from the file and display it,
// until the end of the file is reached.
//
do
{
//
// Read a block of data from the file. Read as much as can fit
// in the temporary buffer, including a space for the trailing null.
//
fresult = f_read(&g_sFileObject, g_cTmpBuf, sizeof(g_cTmpBuf) - 1,
&usBytesRead);
//
// If there was an error reading, then print a newline and
// return the error to the user.
//
if(fresult != FR_OK)
{
UARTprintf("\n");
return(fresult);
}
//
// Null terminate the last block that was read to make it a
// null terminated string that can be used with printf.
//
g_cTmpBuf[usBytesRead] = 0;
//
// Print the last chunk of the file that was received.
//
UARTprintf("%s", g_cTmpBuf);
//
// Continue reading until less than the full number of bytes are
// read. That means the end of the buffer was reached.
//
}
while(usBytesRead == sizeof(g_cTmpBuf) - 1);
//
// Return success.
//.........这里部分代码省略.........
示例2: main
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
//
// Turn on stacking of FPU registers if FPU is used in the ISR.
//
FPULazyStackingEnable();
//
// Set the clocking to run from the PLL at 40MHz.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Set the system tick to fire 100 times per second.
//
ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
ROM_SysTickIntEnable();
ROM_SysTickEnable();
//
// Enable the Debug UART.
//
ConfigureUART();
//
// Print the welcome message to the terminal.
//
UARTprintf("\033[2JAir Mouse Application\n");
//
// Configure desired interrupt priorities. This makes certain that the DCM
// is fed data at a consistent rate. Lower numbers equal higher priority.
//
ROM_IntPrioritySet(INT_I2C3, 0x00);
ROM_IntPrioritySet(INT_GPIOB, 0x10);
ROM_IntPrioritySet(FAULT_SYSTICK, 0x20);
ROM_IntPrioritySet(INT_UART1, 0x60);
ROM_IntPrioritySet(INT_UART0, 0x70);
ROM_IntPrioritySet(INT_WTIMER5B, 0x80);
//
// Configure the USB D+ and D- pins.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);
//
// Pass the USB library our device information, initialize the USB
// controller and connect the device to the bus.
//
USBDHIDMouseCompositeInit(0, &g_sMouseDevice, &g_psCompDevices[0]);
USBDHIDKeyboardCompositeInit(0, &g_sKeyboardDevice, &g_psCompDevices[1]);
//
// Set the USB stack mode to Force Device mode.
//
USBStackModeSet(0, eUSBModeForceDevice, 0);
//
// Pass the device information to the USB library and place the device
// on the bus.
//
USBDCompositeInit(0, &g_sCompDevice, DESCRIPTOR_DATA_SIZE,
g_pui8DescriptorData);
//
// User Interface Init
//
ButtonsInit();
RGBInit(0);
RGBEnable();
//
// Initialize the motion sub system.
//
MotionInit();
//
// Initialize the Radio Systems.
//
LPRFInit();
//
// Drop into the main loop.
//
while(1)
{
//
// Check for and handle timer tick events.
//
if(HWREGBITW(&g_ui32Events, USB_TICK_EVENT) == 1)
{
//.........这里部分代码省略.........
示例3: sensor
//.........这里部分代码省略.........
pfMag[1] *= 1e6;
pfMag[2] *= 1e6;
//
// Convert Eulers to degrees. 180/PI = 57.29...
// Convert Yaw to 0 to 360 to approximate compass headings.
//
pfEulers[0] *= 57.295779513082320876798154814105f;
pfEulers[1] *= 57.295779513082320876798154814105f;
pfEulers[2] *= 57.295779513082320876798154814105f;
if(pfEulers[2] < 0)
{
pfEulers[2] += 360.0f;
}
//
// Now drop back to using the data as a single array for the
// purpose of decomposing the float into a integer part and a
// fraction (decimal) part.
//
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
//
// Conver float value to a integer truncating the decimal part.
//
i32IPart[ui32Idx] = (int32_t) pfData[ui32Idx];
//
// Multiply by 1000 to preserve first three decimal values.
// Truncates at the 3rd decimal place.
//
i32FPart[ui32Idx] = (int32_t) (pfData[ui32Idx] * 1000.0f);
//
// Subtract off the integer part from this newly formed decimal
// part.
//
i32FPart[ui32Idx] = i32FPart[ui32Idx] -
(i32IPart[ui32Idx] * 1000);
//
// make the decimal part a positive number for display.
//
if(i32FPart[ui32Idx] < 0)
{
i32FPart[ui32Idx] *= -1;
}
}
//
// Print the acceleration numbers in the table.
//
UARTprintf("\033[5;17H%3d.%03d", i32IPart[0], i32FPart[0]);
UARTprintf("\033[5;40H%3d.%03d", i32IPart[1], i32FPart[1]);
UARTprintf("\033[5;63H%3d.%03d", i32IPart[2], i32FPart[2]);
//
// Print the angular velocities in the table.
//
UARTprintf("\033[7;17H%3d.%03d", i32IPart[3], i32FPart[3]);
UARTprintf("\033[7;40H%3d.%03d", i32IPart[4], i32FPart[4]);
UARTprintf("\033[7;63H%3d.%03d", i32IPart[5], i32FPart[5]);
//
// Print the magnetic data in the table.
//
UARTprintf("\033[9;17H%3d.%03d", i32IPart[6], i32FPart[6]);
UARTprintf("\033[9;40H%3d.%03d", i32IPart[7], i32FPart[7]);
UARTprintf("\033[9;63H%3d.%03d", i32IPart[8], i32FPart[8]);
//
// Print the Eulers in a table.
//
UARTprintf("\033[14;17H%3d.%03d", i32IPart[9], i32FPart[9]);
UARTprintf("\033[14;40H%3d.%03d", i32IPart[10], i32FPart[10]);
UARTprintf("\033[14;63H%3d.%03d", i32IPart[11], i32FPart[11]);
//
// Print the quaternions in a table format.
//
UARTprintf("\033[19;14H%3d.%03d", i32IPart[12], i32FPart[12]);
UARTprintf("\033[19;32H%3d.%03d", i32IPart[13], i32FPart[13]);
UARTprintf("\033[19;50H%3d.%03d", i32IPart[14], i32FPart[14]);
UARTprintf("\033[19;68H%3d.%03d", i32IPart[15], i32FPart[15]);
// currentSpeed=i32IPart[9]; how to get velocity from speed
}
return pitch= i32IPart[9];
}
示例4: main
//*****************************************************************************
//
// This is the main example program. It checks to see that the interrupts are
// processed in the correct order when they have identical priorities,
// increasing priorities, and decreasing priorities. This exercises interrupt
// preemption and tail chaining.
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32Error;
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();
//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Enable the peripherals used by this example.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
//
// Initialize the UART.
//
ConfigureUART();
UARTprintf("\033[2JInterrupts\n");
//
// Configure the PB0-PB2 to be outputs to indicate entry/exit of one
// of the interrupt handlers.
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 |
GPIO_PIN_3);
ROM_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, 0);
//
// Set up and enable the SysTick timer. It will be used as a reference
// for delay loops in the interrupt handlers. The SysTick timer period
// will be set up for one second.
//
ROM_SysTickPeriodSet(ROM_SysCtlClockGet());
ROM_SysTickEnable();
//
// Reset the error indicator.
//
ui32Error = 0;
//
// Enable interrupts to the processor.
//
ROM_IntMasterEnable();
//
// Enable the interrupts.
//
ROM_IntEnable(INT_GPIOA);
ROM_IntEnable(INT_GPIOB);
ROM_IntEnable(INT_GPIOC);
//
// Indicate that the equal interrupt priority test is beginning.
//
UARTprintf("\nEqual Priority\n");
//
// Set the interrupt priorities so they are all equal.
//
ROM_IntPrioritySet(INT_GPIOA, 0x00);
ROM_IntPrioritySet(INT_GPIOB, 0x00);
ROM_IntPrioritySet(INT_GPIOC, 0x00);
//
// Reset the interrupt flags.
//
g_ui32GPIOa = 0;
g_ui32GPIOb = 0;
g_ui32GPIOc = 0;
g_ui32Index = 1;
//
// Trigger the interrupt for GPIO C.
//
HWREG(NVIC_SW_TRIG) = INT_GPIOC - 16;
//
// Put the current interrupt state on the LCD.
//
DisplayIntStatus();
//.........这里部分代码省略.........
示例5: main
//*****************************************************************************
// This example demonstrates MIDI functionality and control methods
//*****************************************************************************
int main(void){
// Set the clocking to run directly from the crystal.
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
// Enable the peripherals used by this VS1053.
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); // VS1053 Serial
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // VS1053 Serial
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // VS1053 Reset + EMG Input
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); // EMG Input 1
// Enable PC Console
InitSerial();
// Enable processor interrupts.
IntMasterEnable();
// Set GPIO B0 and B1 as UART pins for VS1053 Control
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// Set GPIO E4 as Hardware Reset pin and E5 as ADC Input
GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_4);
GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5);
// Configure the UART1 as according to VS1053 Datasheet with baudrate of 31250
UARTConfigSetExpClk(UART1_BASE, ROM_SysCtlClockGet(), 31250, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
// Setup ADC Sampling Sequences 3, configure step 0.
// Note: Sequence 1 and 2 has 4 step, which would be great for 3-channel sampling
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 3);
// Example Started
UARTprintf("VS1053 Test\n");
// Reset the VS1053
VS1053_Reset();
// Setup the MIDI Channel 0
midiSetChannelBank(0, VS1053_BANK_MELODY);
midiSetInstrument(0, VS1053_GM1_OCARINA);
midiSetChannelVolume(0, 127);
midiNoteOn(0, 70, 127);
Delay(1000);
// Setup the MIDI Channel 1
midiSetChannelBank(1, VS1053_BANK_MELODY);
midiSetInstrument(1, VS1053_GM1_OCARINA);
midiSetChannelVolume(1, 0);
midiNoteOn(1, 60, 127);
// Setup variables for ADC
uint32_t ADC_Output[1];
uint8_t volume;
// Infinite Loop of execution
while(1)
{
// ADC Sampling Procedures
ADCProcessorTrigger(ADC0_BASE, 3);
while(!ADCIntStatus(ADC0_BASE, 3, false)) {}
ADCIntClear(ADC0_BASE, 3);
ADCSequenceDataGet(ADC0_BASE, 3, ADC_Output);
UARTprintf("AIN8 = %4d\n", ADC_Output[0]);
// Play Sound as according to voltage level
volume = inputMapping(ADC_Output[0], 3000, 4000, 50, 127);
midiSetChannelVolume(0, volume);
UARTprintf("Volume Level = %4d\n", volume);
// Delay
Delay(100);
}
}
示例6: USBHCDEvents
//*****************************************************************************
//
// This is the generic callback from host stack.
//
// pvData is actually a pointer to a tEventInfo structure.
//
// This function will be called to inform the application when a USB event has
// occurred that is outside those related to the keyboard device. At this
// point this is used to detect unsupported devices being inserted and removed.
// It is also used to inform the application when a power fault has occurred.
// This function is required when the g_USBGenericEventDriver is included in
// the host controller driver array that is passed in to the
// USBHCDRegisterDrivers() function.
//
//*****************************************************************************
void
USBHCDEvents(void *pvData)
{
tEventInfo *pEventInfo;
//
// Cast this pointer to its actual type.
//
pEventInfo = (tEventInfo *)pvData;
switch(pEventInfo->ulEvent)
{
//
// New keyboard detected.
//
case USB_EVENT_CONNECTED:
{
//
// See if this is a HID Keyboard.
//
if((USBHCDDevClass(pEventInfo->ulInstance, 0) == USB_CLASS_HID) &&
(USBHCDDevProtocol(pEventInfo->ulInstance, 0) ==
USB_HID_PROTOCOL_KEYB))
{
//
// Indicate that the keyboard has been detected.
//
UARTprintf("Keyboard Connected\n");
//
// Proceed to the STATE_KEYBOARD_INIT state so that the main
// loop can finish initialized the mouse since
// USBHKeyboardInit() cannot be called from within a callback.
//
g_eUSBState = STATE_KEYBOARD_INIT;
}
break;
}
//
// Unsupported device detected.
//
case USB_EVENT_UNKNOWN_CONNECTED:
{
UARTprintf("Unsupported Device Connected\n");
//
// An unsupported device was detected.
//
g_eUSBState = STATE_UNKNOWN_DEVICE;
UpdateStatus();
break;
}
//
// Device has been unplugged.
//
case USB_EVENT_DISCONNECTED:
{
//
// Indicate that the device has been disconnected.
//
UARTprintf("Device Disconnected\n");
//
// Change the state so that the main loop knows that the device
// is no longer present.
//
g_eUSBState = STATE_NO_DEVICE;
//
// Update the screen.
//
UpdateStatus();
break;
}
//
// Power Fault has occurred.
//
case USB_EVENT_POWER_FAULT:
{
UARTprintf("Power Fault\n");
//.........这里部分代码省略.........
示例7: main
//*****************************************************************************
//
// Main 'C' Language entry point.
//
//*****************************************************************************
int
main(void)
{
float fTemperature, fPressure, fAltitude;
int32_t i32IntegerPart;
int32_t i32FractionPart;
//
// Setup the system clock to run at 40 MHz from PLL with crystal reference
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
//
// Initialize the UART.
//
ConfigureUART();
//
// Print the welcome message to the terminal.
//
UARTprintf("\033[2JBMP180 Example\n");
//
// Set the color to a white approximation.
//
g_pui32Colors[RED] = 0x8000;
g_pui32Colors[BLUE] = 0x8000;
g_pui32Colors[GREEN] = 0x8000;
//
// Initialize RGB driver. Use a default intensity and blink rate.
//
RGBInit(0);
RGBColorSet(g_pui32Colors);
RGBIntensitySet(0.5f);
RGBEnable();
//
// The I2C3 peripheral must be enabled before use.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// Configure the pin muxing for I2C3 functions on port D0 and D1.
// This step is not necessary if your part does not support pin muxing.
//
ROM_GPIOPinConfigure(GPIO_PD0_I2C3SCL);
ROM_GPIOPinConfigure(GPIO_PD1_I2C3SDA);
//
// Select the I2C function for these pins. This function will also
// configure the GPIO pins pins for I2C operation, setting them to
// open-drain operation with weak pull-ups. Consult the data sheet
// to see which functions are allocated per pin.
//
GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
ROM_GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
//
// Initialize the GPIO for the LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x00);
//
// Enable interrupts to the processor.
//
ROM_IntMasterEnable();
//
// Initialize the I2C3 peripheral.
//
I2CMInit(&g_sI2CInst, I2C3_BASE, INT_I2C3, 0xff, 0xff,
ROM_SysCtlClockGet());
//
// Initialize the BMP180.
//
BMP180Init(&g_sBMP180Inst, &g_sI2CInst, BMP180_I2C_ADDRESS,
BMP180AppCallback, &g_sBMP180Inst);
//
// Wait for initialization callback to indicate reset request is complete.
//
while(g_vui8DataFlag == 0)
{
//
// Wait for I2C Transactions to complete.
//
}
//
//.........这里部分代码省略.........
示例8: DESInit
//*****************************************************************************
//
// Initialize the DES and CCM modules.
//
//*****************************************************************************
bool
DESInit(void)
{
uint32_t ui32Loop;
//
// Check that the CCM peripheral is present.
//
if(!ROM_SysCtlPeripheralPresent(SYSCTL_PERIPH_CCM0))
{
UARTprintf("No CCM peripheral found!\n");
//
// Return failure.
//
return(false);
}
//
// The hardware is available, enable it.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_CCM0);
//
// Wait for the peripheral to be ready.
//
ui32Loop = 0;
while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0))
{
//
// Increment our poll counter.
//
ui32Loop++;
if(ui32Loop > CCM_LOOP_TIMEOUT)
{
//
// Timed out, notify and spin.
//
UARTprintf("Time out on CCM ready after enable.\n");
//
// Return failure.
//
return(false);
}
}
//
// Reset the peripheral to ensure we are starting from a known condition.
//
ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_CCM0);
//
// Wait for the peripheral to be ready again.
//
ui32Loop = 0;
while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0))
{
//
// Increment our poll counter.
//
ui32Loop++;
if(ui32Loop > CCM_LOOP_TIMEOUT)
{
//
// Timed out, spin.
//
UARTprintf("Time out on CCM ready after reset.\n");
//
// Return failure.
//
return(false);
}
}
//
// Return initialization success.
//
return(true);
}
示例9: main
//*****************************************************************************
//
// This example encrypts blocks of plaintext using TDES in CBC mode. It
// does the encryption first without uDMA and then with uDMA. The results
// are checked after each operation.
//
//*****************************************************************************
int
main(void)
{
uint32_t pui32CipherText[16], ui32Errors, ui32Idx, ui32SysClock;
//
// Run from the PLL at 120 MHz.
//
ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet(false, false);
//
// Initialize local variables.
//
ui32Errors = 0;
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
pui32CipherText[ui32Idx] = 0;
}
//
// Enable stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPUStackingEnable();
//
// Enable DES interrupts.
//
ROM_IntEnable(INT_DES0);
//
// Enable debug output on UART0 and print a welcome message.
//
ConfigureUART();
UARTprintf("Starting TDES CBC encryption demo.\n");
//
// Enable the uDMA module.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
//
// Setup the control table.
//
ROM_uDMAEnable();
ROM_uDMAControlBaseSet(g_psDMAControlTable);
//
// Initialize the CCM and DES modules.
//
if(!DESInit())
{
UARTprintf("Initialization of the DES module failed.\n");
ui32Errors |= 0x00000001;
}
//
// Perform the encryption without uDMA.
//
UARTprintf("Performing encryption without uDMA.\n");
TDESCBCEncrypt(g_pui32TDESPlainText, pui32CipherText, g_pui32TDESKey,
64, g_pui32TDESIV, false);
//
// Check the result.
//
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
if(pui32CipherText[ui32Idx] != g_pui32TDESCipherText[ui32Idx])
{
UARTprintf("Ciphertext mismatch on word %d. Exp: 0x%x, Act: "
"0x%x\n", ui32Idx, g_pui32TDESCipherText[ui32Idx],
pui32CipherText[ui32Idx]);
ui32Errors |= (ui32Idx << 16) | 0x00000002;
}
}
//
// Clear the array containing the ciphertext.
//
for(ui32Idx = 0; ui32Idx < 16; ui32Idx++)
{
pui32CipherText[ui32Idx] = 0;
}
//.........这里部分代码省略.........
示例10: NodeMain
// *************** NodeMain **************
// Main task for the sensor node. This task runs a simple sensor task "scheduler"
// that runs periodically based on the GCF of all sensor's sampling rates, MinSampRate.
// Every sensor is run after a certain number of MinSampRate intervals has passed. Note
// that this is not a real-time scheduler. It assumes that all sensor tasks can run to
// completion within the MinSampRate time, which is at most 1 second.
static void NodeMain( void )
{
SENSOR_MSG_T sensor_msg;
Message transceiver_msg;
char *transceiver_msg_data;
unsigned long i;
unsigned long delay_time;
int (*task)( PORT_T *port );
#if ENABLE_UART_PRINTF
UARTprintf( "\nNode Main\n" );
UARTprintf( "---------\n\n" );
#endif
// XXX Need to add semaphore so NodeMain doesn't run while any sensorInit* tasks are running
for( ;; )
{
delay_time = 3;
// Update the sampling rates if any sampling rate has changed
if( 1 == SampRateChanged )
{
taskENTER_CRITICAL();
updateSamplingRates();
SampRateChanged = 0;
taskEXIT_CRITICAL();
}
// Check if there are active sensors
if( NumActiveSensors > 0 )
{
LED_Off( LED2 );
if( 0 == MinSampRate )
{
#if ENABLE_UART_PRINTF
UARTprintf( "MinSampRate = 0 - put node to sleep\n" );
#endif
}
else
{
// Sensor Task Scheduler
// Note that we assume all tasks can run in well under 1 second. If any tasks take
// longer to run, we need to implement a "background task" that sensor drivers can use.
delay_time = MinSampRate;
for( i = 0; i < 1; i++ )
{
if( SensorSampRateTicks[i] == 0 )
{
SensorSampRateTicks[i] = SensorSampRateTicksReset[i];
switch ( i )
{
case 0:
SensorTask1( SensorPort[i] );
break;
case 1:
SensorTask2( SensorPort[i] );
break;
case 2:
SensorTask3( SensorPort[i] );
break;
case 3:
SensorTask4( SensorPort[i] );
break;
default:
break;
}
}
else
{
if( SensorSampRateTicks[i] != -1 )
{
SensorSampRateTicks[i]--;
}
}
// Process messages sent by each sensor, send them either to the transceiver
// or to another sensor on the node. Other destination IDs for sensor messages
// could be added in the future. For example, messages could be sent to a
// a message log on the node, or potentially to other nodes in the network.
// XXX
// Each sensor sends messages directly to the Transceiver Queue, more efficient
// due to the implementation of the xQueue data structure (passing whole messages
// is costly). An improved version would have message handling done here, so that
// sensor messages could be sent to the transceiver or another location depending
// on message id. This would allow messages between sensors, message backup,
// message logging, etc.
/*
if( pdTRUE == xQueueReceive( (xQueueHandle)SensorPort[i]->tx_fifo, &sensor_msg, 0 ) )
{
// Print message
UARTprintf( "dest_id: %d\n", sensor_msg.dest_id );
//.........这里部分代码省略.........
示例11: TDESCBCEncrypt
//*****************************************************************************
//
// Perform an encryption operation.
//
//*****************************************************************************
bool
TDESCBCEncrypt(uint32_t *pui32Src, uint32_t *pui32Dst, uint32_t *pui32Key,
uint32_t ui32Length, uint32_t *pui32IV, bool bUseDMA)
{
//
// Perform a soft reset.
//
ROM_DESReset(DES_BASE);
//
// Clear the interrupt flags.
//
g_bContextInIntFlag = false;
g_bDataInIntFlag = false;
g_bDataOutIntFlag = false;
g_bContextInDMADoneIntFlag = false;
g_bDataInDMADoneIntFlag = false;
g_bDataOutDMADoneIntFlag = false;
//
// Enable all interrupts.
//
ROM_DESIntEnable(DES_BASE, (DES_INT_CONTEXT_IN |
DES_INT_DATA_IN | DES_INT_DATA_OUT));
//
// Configure the DES module.
//
ROM_DESConfigSet(DES_BASE, (DES_CFG_DIR_ENCRYPT | DES_CFG_TRIPLE |
DES_CFG_MODE_CBC));
//
// Write the key.
//
ROM_DESKeySet(DES_BASE, pui32Key);
//
// Write the IV.
//
ROM_DESIVSet(DES_BASE, pui32IV);
//
// Depending on the argument, perform the encryption
// with or without uDMA.
//
if(bUseDMA)
{
//
// Enable DMA interrupts.
//
ROM_DESIntEnable(DES_BASE, (DES_INT_DMA_CONTEXT_IN |
DES_INT_DMA_DATA_IN |
DES_INT_DMA_DATA_OUT));
//
// Setup the DMA module to copy data in.
//
ROM_uDMAChannelAssign(UDMA_CH21_DES0DIN);
ROM_uDMAChannelAttributeDisable(UDMA_CH21_DES0DIN,
UDMA_ATTR_ALTSELECT |
UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
ROM_uDMAChannelControlSet(UDMA_CH21_DES0DIN | UDMA_PRI_SELECT,
UDMA_SIZE_32 | UDMA_SRC_INC_32 |
UDMA_DST_INC_NONE | UDMA_ARB_2 |
UDMA_DST_PROT_PRIV);
ROM_uDMAChannelTransferSet(UDMA_CH21_DES0DIN | UDMA_PRI_SELECT,
UDMA_MODE_BASIC, (void *)pui32Src,
(void *)(DES_BASE + DES_O_DATA_L),
LengthRoundUp(ui32Length) / 4);
UARTprintf("Data in DMA request enabled.\n");
//
// Setup the DMA module to copy the data out.
//
ROM_uDMAChannelAssign(UDMA_CH22_DES0DOUT);
ROM_uDMAChannelAttributeDisable(UDMA_CH22_DES0DOUT,
UDMA_ATTR_ALTSELECT |
UDMA_ATTR_USEBURST |
UDMA_ATTR_HIGH_PRIORITY |
UDMA_ATTR_REQMASK);
ROM_uDMAChannelControlSet(UDMA_CH22_DES0DOUT | UDMA_PRI_SELECT,
UDMA_SIZE_32 | UDMA_SRC_INC_NONE |
UDMA_DST_INC_32 | UDMA_ARB_2 |
UDMA_SRC_PROT_PRIV);
ROM_uDMAChannelTransferSet(UDMA_CH22_DES0DOUT | UDMA_PRI_SELECT,
UDMA_MODE_BASIC,
(void *)(DES_BASE + DES_O_DATA_L),
(void *)pui32Dst,
LengthRoundUp(ui32Length) / 4);
UARTprintf("Data out DMA request enabled.\n");
//
// Enable DMA requests
//.........这里部分代码省略.........
示例12: FATFontWrapperLoad
//*****************************************************************************
//
// Prepares a font in the FATfs file system for use by the graphics library.
//
// This function must be called to prepare a font for use by the graphics
// library. It opens the font file whose name is passed and reads the
// header information. The value returned should be written into the
// pucFontId field of the tFontWrapper structure that will be passed to
// graphics library.
//
// This is a very simple (and slow) implementation. More complex wrappers
// may also initialize a glyph cache here.
//
// \return On success, returns a non-zero pointer identifying the font. On
// error, zero is returned.
//
//*****************************************************************************
unsigned char *
FATFontWrapperLoad(char *pcFilename)
{
FRESULT fresult;
WORD ulRead, ulToRead;
UARTprintf("Attempting to load font %s from FAT file system.\n",
pcFilename);
//
// Make sure a font is not already open.
//
if(g_sFontFile.bInUse)
{
//
// Oops - someone tried to load a new font without unloading the
// previous one.
//
UARTprintf("Another font is already loaded!\n");
return(0);
}
//
// Try to open the file whose name we've been given.
//
fresult = f_open(&g_sFontFile.sFile, pcFilename, FA_READ);
if(fresult != FR_OK)
{
//
// We can't open the file. Either the file doesn't exist or there is
// no SDCard installed. Regardless, return an error.
//
UARTprintf("Error %s (%d) from f_open.\n", StringFromFresult(fresult),
fresult);
return(0);
}
//
// We opened the file successfully. Does it seem to contain a valid
// font? Read the header and see.
//
fresult = f_read(&g_sFontFile.sFile, &g_sFontFile.sFontHeader,
sizeof(tFontWide), &ulRead);
if((fresult == FR_OK) && (ulRead == sizeof(tFontWide)))
{
//
// We read the font header. Is the format correct? We only support
// wide fonts via wrappers.
//
if((g_sFontFile.sFontHeader.ucFormat != FONT_FMT_WIDE_UNCOMPRESSED) &&
(g_sFontFile.sFontHeader.ucFormat != FONT_FMT_WIDE_PIXEL_RLE))
{
//
// This is not a supported font format.
//
UARTprintf("Unrecognized font format. Failing "
"FATFontWrapperLoad.\n");
f_close(&g_sFontFile.sFile);
return(0);
}
//
// The format seems to be correct so read as many block headers as we
// have storage for.
//
ulToRead = (g_sFontFile.sFontHeader.usNumBlocks > MAX_FONT_BLOCKS) ?
MAX_FONT_BLOCKS * sizeof(tFontBlock) :
g_sFontFile.sFontHeader.usNumBlocks * sizeof(tFontBlock);
fresult = f_read(&g_sFontFile.sFile, &g_sFontFile.pBlocks, ulToRead,
&ulRead);
if((fresult == FR_OK) && (ulRead == ulToRead))
{
//
// All is well. Tell the caller the font was opened successfully.
//
UARTprintf("Font %s opened successfully.\n", pcFilename);
g_sFontFile.bInUse = true;
return((unsigned char *)&g_sFontFile);
}
else
{
UARTprintf("Error %s (%d) reading block headers. Read %d, exp %d bytes.\n",
//.........这里部分代码省略.........
示例13: FATWrapperFontBlockCodepointsGet
//*****************************************************************************
//
// Returns information on the glyphs contained within a given font block.
//
//*****************************************************************************
static unsigned long
FATWrapperFontBlockCodepointsGet(unsigned char *pucFontId,
unsigned short usBlockIndex,
unsigned long *pulStart)
{
tFontBlock sBlock;
tFontFile *pFont;
tBoolean bRetcode;
//
// Parameter sanity check.
//
ASSERT(pucFontId);
//
// Get a pointer to our instance data.
//
pFont = (tFontFile *)pucFontId;
ASSERT(pFont->bInUse);
//
// Have we been passed a valid block index?
//
if(usBlockIndex >= pFont->sFontHeader.usNumBlocks)
{
//
// No - return an error.
//
return(0);
}
//
// Is this block header cached?
//
if(usBlockIndex < MAX_FONT_BLOCKS)
{
//
// Yes - return the information from our cached copy.
//
*pulStart = pFont->pBlocks[usBlockIndex].ulStartCodepoint;
return(pFont->pBlocks[usBlockIndex].ulNumCodepoints);
}
else
{
//
// We don't have the block header cached so read it from the
// SDCard. First move the file pointer to the expected position.
//
bRetcode = FATWrapperFontBlockHeaderGet(&pFont->sFile, &sBlock,
usBlockIndex);
if(bRetcode)
{
*pulStart = sBlock.ulStartCodepoint;
return(sBlock.ulNumCodepoints);
}
else
{
UARTprintf("Error reading block header!\n");
}
}
//
// If we get here, something horrible happened so return a failure.
//
*pulStart = 0;
return(0);
}
示例14: main
//
// Main - It performs initialization, then runs a command processing loop to
// read commands from the console.
//
int
main(void)
{
int nStatus;
FRESULT fresult;
//
// Set the clocking to run from the PLL at 50MHz
//
SysCtlClockSet(SYSCTL_OSCSRC_OSC2 | SYSCTL_PLL_ENABLE | SYSCTL_IMULT(10) |
SYSCTL_SYSDIV(2));
SysCtlAuxClockSet(SYSCTL_OSCSRC_OSC2 | SYSCTL_PLL_ENABLE |
SYSCTL_IMULT(12) | SYSCTL_SYSDIV(2)); //60 MHz
#ifdef _FLASH
//
// Copy time critical code and Flash setup code to RAM
// This includes the following functions: InitFlash_Bank0();
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart
// symbols are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
//
// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
//
InitFlash_Bank0();
#endif
//
// Initialize interrupt controller and vector table
//
InitPieCtrl();
InitPieVectTable();
//
// Set the system tick to fire 100 times per second.
//
SysTickInit();
SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / 100);
SysTickIntRegister(SysTickHandler);
SysTickIntEnable();
SysTickEnable();
//
// Enable Interrupts
//
IntMasterEnable();
//
// Configure UART0 for debug output.
//
ConfigureUART();
//
// Print hello message to user.
//
UARTprintf("\n\nSD Card Example Program\n");
UARTprintf("Type \'help\' for help.\n");
//
// Mount the file system, using logical disk 0.
//
fresult = f_mount(0, &g_sFatFs);
if(fresult != FR_OK)
{
UARTprintf("f_mount error: %s\n", StringFromFresult(fresult));
return(1);
}
//
// Enter an (almost) infinite loop for reading and processing commands from
// the user.
//
while(1)
{
//
// Print a prompt to the console. Show the CWD.
//
UARTprintf("\n%s> ", g_cCwdBuf);
//
// Get a line of text from the user.
//
UARTgets(g_cCmdBuf, sizeof(g_cCmdBuf));
//
// Pass the line from the user to the command processor.
// It will be parsed and valid commands executed.
//
nStatus = CmdLineProcess(g_cCmdBuf);
//
// Handle the case of bad command.
//
//.........这里部分代码省略.........
示例15: MPU9250_Init
void MPU9250_Init()
{
uint32_t Device_ID;
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_7);
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5);
GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_3, SSI_MODE_MASTER, 1000000, 8);
SSIEnable(SSI0_BASE);
//
// Display the example setup on the console.
//
UARTprintf("\nPower up.\n");
// MPU-6500 Device ID check and initial
Device_ID = 0x0;
Device_ID = MPU9250_ReadReg(MPU6500_WHO_AM_I);
if(Device_ID == MPU6500_Device_ID)
{
UARTprintf("MPU6500 Device ID: 0x%X\n--- MPU6500 Initialization done.\n", Device_ID);
}
else
{
OLED_Print(0,0,"MPU6500 ERR");
UARTprintf("MPU6500 Device ID: 0x%X\n--- MPU6500 Initialization error.\n", Device_ID);
while (1);
}
MPU9250_SetParameter();
#ifdef USE_MAG
// AK9875 Device ID check
// if AK9875 ID check check failed with no reason, re-power-up the system.
MPU9250_WriteAuxReg(AK8963_CNTL2, 0x01); //soft reset
MPU9250_Delay_nop(100000);
Device_ID = 0x00;
Device_ID = MPU9250_ReadAuxReg(AK8963_WIA);
if(Device_ID == AK8963_Device_ID)
{
UARTprintf("AK8963 Device ID: 0x%X\n--- AK8963 Initialization done.\n", Device_ID);
LED_Blue_Off();
}
else
{
UARTprintf("AK8963 Device ID: 0x%X\n--- AK8963 Initialization error.\n", Device_ID);
OLED_Print(0,0,"AK8963 Init ERR");
LED_Red_Off();
LED_Green_Off();
}
MPU9250_GetMagAdjValue();
MPU9250_WriteAuxReg(AK8963_CNTL1, 0x16); // 16-bits, Rate 100Hz
//MPU9250_WriteAuxReg(AK8963_CNTL1, 0x2); // 14-bits, Rate 8Hz
Device_ID = MPU9250_ReadAuxReg(AK8963_CNTL1);
#else
UARTprintf("AK8963 is disabled.\n");
#endif
}