void uart3InitBuffers(void) { #ifndef UART_BUFFER_EXTERNAL_RAM // initialize the UART1 buffers bufferInit(&uartRxBuffer[3], (u08*)uart3RxData, UART3_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[3], (u08*)uart3TxData, UART3_TX_BUFFER_SIZE); #else // initialize the UART1 buffers bufferInit(&uartRxBuffer[3], (u08*) UART3_RX_BUFFER_ADDR, UART3_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[3], (u08*) UART3_TX_BUFFER_ADDR, UART3_TX_BUFFER_SIZE); #endif }
void uart1InitBuffers(void) { #ifndef UART_BUFFER_EXTERNAL_RAM // initialize the UART1 buffers bufferInit(&uartRxBuffer[1], (uint8_t*) uart1RxData, UART1_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[1], (uint8_t*) uart1TxData, UART1_TX_BUFFER_SIZE); #else // initialize the UART1 buffers bufferInit(&uartRxBuffer[1], (uint8_t*) UART1_RX_BUFFER_ADDR, UART1_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[1], (uint8_t*) UART1_TX_BUFFER_ADDR, UART1_TX_BUFFER_SIZE); #endif }
void uart0InitBuffers(void) { #ifndef UART_BUFFERS_EXTERNAL_RAM // initialize the UART0 buffers bufferInit(&uartRxBuffer[0], uart0RxData, UART0_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[0], uart0TxData, UART0_TX_BUFFER_SIZE); #else // initialize the UART0 buffers bufferInit(&uartRxBuffer[0], (u08*) UART0_RX_BUFFER_ADDR, UART0_RX_BUFFER_SIZE); bufferInit(&uartTxBuffer[0], (u08*) UART0_TX_BUFFER_ADDR, UART0_TX_BUFFER_SIZE); #endif }
static DUMP_INFO* dumpStruct( // DUMP A STRUCTURE TYPE type, // - structure type DUMP_INFO* di, // - dump information char* title, // - title for dump ds_control control ) // - control word { CLASSINFO* info; // - class information NAME *parent; // - where parent ptr is stored control = control; type = StructType( type ); info = type->u.c.info; parent = VstkPush( &di->stack ); *parent = info->name; di = dumpTitle( di, title, NameStr( info->name ) ); if( type != di->original ) { di = bufferInit( di ); di = bufferStr( di, "embedded size: " ); di = bufferNmb( di, info->vsize ); di = bufferWrite( di ); di = dumpOffset( di ); di = dumpParentage( di ); } else { di = bufferInit( di ); di = bufferStr( di, "size: " ); di = bufferNmb( di, info->size ); di = bufferWrite( di ); } if( info->has_vbptr ) { di = dumpDataMemb( di , "[virtual" , "base pointer]" , info->vb_offset + di->offset , CgMemorySize( TypePtrToVoid() ) ); } if( info->has_vfptr ) { di = dumpDataMemb( di , "[virtual" , "functions pointer]" , info->vf_offset + di->offset , CgMemorySize( TypePtrToVoid() ) ); } ScopeWalkDataMembers( type->u.c.scope, dumpMember, di ); if( type == di->original ) { ScopeWalkVirtualBases( type->u.c.scope, dumpVirtual, di ); } ScopeWalkDirectBases( type->u.c.scope, dumpDirect, di ); VstkPop( &di->stack ); return di; }
// create and initialize the uart transmit and receive buffers void uartInitBuffers(void) { #ifndef UART_BUFFERS_EXTERNAL_RAM // initialize the UART receive buffer bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE); // initialize the UART transmit buffer bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE); #else // initialize the UART receive buffer bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE); // initialize the UART transmit buffer bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE); #endif }
// create and initialize the uart transmit and receive buffers void uartInitBuffers(void) { // initialize the UART receive buffer bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE); // initialize the UART transmit buffer //bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE); }
int main( void ) { char str[] = "DEADBEEF"; unsigned char *tmp; int i=0, res; bufferInit( &myBuff, serial_link, 256 ); stxetxInit( put_char ); stxetxSend( 0, 0, strlen( str ), (unsigned char*) str ); // Now parse the package byte by until the receive function claims success. printf( "\nStarting parsing" ); res = stxetxProcess( &myBuff ); #if 0 do { res = stxetxProcess( &myBuff ); printf( "." ); } while ( res ); #endif printf( "\nFinnished parsing!\n" ); tmp = stxetxGetRxPacketData(); for ( i = 0; i < stxetxGetRxPacketDatalength(); i++ ) { printf( "%x ", *tmp ); // Show the received data tmp++; } printf( "\n" ); return 0; }
void sdk_mem_init(void) { if (g_sdk_mem_inited) return; g_sdk_mem_inited = FH_TRUE; bufferInit((unsigned char *)FH_SDK_MEM_START, FH_SDK_MEM_SIZE); }
void uart2Init(uint16_t bauddiv, uint32_t mode) { // enable the clock of DBGU AT91C_BASE_PMC->PMC_PCER = (1<<AT91C_ID_SYS); // enable uart pins on PIO *AT91C_PIOA_PDR = AT91C_PA9_DRXD | AT91C_PA10_DTXD; // disable I/O pullup *AT91C_PIOA_PPUDR = AT91C_PA9_DRXD; // reset the UART pUSART2->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS |AT91C_US_TXDIS; // set serial line mode pUSART2->US_MR = AT91C_US_USMODE_NORMAL | // Normal Mode AT91C_US_CLKS_CLOCK | // Clock = MCK AT91C_US_CHRL_8_BITS | // 8-bit Data (no effect on DBGU) AT91C_US_PAR_NONE | // No Parity AT91C_US_NBSTOP_1_BIT; // 1 Stop Bit (no effect on DBGU) // set the baud rate pUSART2->US_BRGR = bauddiv; // enable the uart pUSART2->US_CR = AT91C_US_RXEN | AT91C_US_TXEN; // initialize buffers bufferInit(&uartRxBuffer[2], uart2RxData, UART2_RX_BUFFER_SIZE); //bufferInit(&uartTxBuffer[2], uart2TxData, UART2_TX_BUFFER_SIZE); // attach interrupt handler processorAicAttachSys(SYSPID_DBGU, uart2Service); // enable receive interrupt pUSART2->US_IER = AT91C_US_RXRDY; }
void uart1Init(uint16_t bauddiv, uint32_t mode) { // enable the clock of UART1 AT91C_BASE_PMC->PMC_PCER = (1<<AT91C_ID_US1); // enable uart pins on PIO *AT91C_PIOA_PDR = AT91C_PA21_RXD1 | AT91C_PA22_TXD1; // select peripheral connection *AT91C_PIOA_ASR = AT91C_PA21_RXD1 | AT91C_PA22_TXD1; // disable I/O pullup *AT91C_PIOA_PPUDR = AT91C_PA21_RXD1; // reset the UART pUSART2->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS |AT91C_US_TXDIS; // set serial line mode pUSART1->US_MR = AT91C_US_USMODE_NORMAL |// Normal Mode AT91C_US_CLKS_CLOCK | // Clock = MCK mode; // user-defined data parameters // set the baud rate pUSART1->US_BRGR = bauddiv; // enable the uart pUSART1->US_CR = AT91C_US_RXEN | AT91C_US_TXEN; // initialize buffers bufferInit(&uartRxBuffer[1], uart1RxData, UART1_RX_BUFFER_SIZE); //bufferInit(&uartTxBuffer[1], uart1TxData, UART1_TX_BUFFER_SIZE); // attach interrupt handler processorAicAttach(AT91C_ID_US1, (UART1_INTERRUPT_LEVEL|AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL), uart1Service); // enable receive interrupt pUSART1->US_IER = AT91C_US_RXRDY; }
static DUMP_INFO* dumpOffset( // DUMP OFFSET LINE DUMP_INFO* di ) // - dump information { di = bufferInit( di ); di = bufferStr( di, "offset of class: " ); di = bufferNmb( di, di->offset ); di = bufferWrite( di ); return di; }
/* * Default constructor */ BufferManager::BufferManager() { bufferInit(&bufferGPS, MAXSIZE_GPS, sizeof(SCoordinate)); bufferInit(&bufferLinearAcceleration, MAXSIZE_LINEARACCELERATION, sizeof(SLinearAcceleration)); bufferInit(&bufferAngularAcceleration, MAXSIZE_ANGULARACCELERATION, sizeof(SAngularAcceleration)); bufferInit(&bufferHumidity, MAXSIZE_HUMIDITY, sizeof(SHumidity)); bufferInit(&bufferTemperature, MAXSIZE_TEMPERATURE, sizeof(STemperature)); bufferInit(&bufferLight, MAXSIZE_LIGHT, sizeof(SLight)); bufferInit(&bufferAlert, MAXSIZE_ALERT, sizeof(SAlert)); }
static DUMP_INFO* dumpParentage( // DUMP PARENTAGE DUMP_INFO* di ) // - dump information { char**daughter; // - daughter class for( daughter = VstkTop( &di->stack ); ; ) { daughter = VstkNext( &di->stack, daughter ); if( daughter == NULL ) break; di = bufferInit( di ); di = bufferStr( di, "base of: " ); di = bufferStr( di, *daughter ); di = bufferWrite( di ); } return di; }
Clouds::Clouds(unsigned int screenResolutionX, unsigned int screenResolutionY, float farPlaneDistance, ScreenAlignedTriangle& screenTri) : screenResolutionX(screenResolutionX), screenResolutionY(screenResolutionY), farPlaneDistance(farPlaneDistance), moveShader(new ShaderObject("Shader\\cloudMove.vert", "", "", transformFeedbackVaryings, 3, false)), fomShader(new ShaderObject("Shader\\cloudPassThrough.vert", "Shader\\cloudFOM.frag", "Shader\\cloudFOM.geom")), fomFilterShader(new ShaderObject("Shader\\screenTri.vert", "Shader\\cloudFOMBlur.frag")), renderingShader(new ShaderObject("Shader\\cloudPassThrough.vert", "Shader\\cloudRendering.frag", "Shader\\cloudRendering.geom")), particleDepthBuffer(new float[maxNumCloudParticles]), particleIndexBuffer(new unsigned short[maxNumCloudParticles]), screenTri(screenTri) { shaderInit(); fboInit(); bufferInit(); samplerInit(); noiseInit(); }
static DUMP_INFO* dumpDataMemb( // DUMP A DATA MEMBER DUMP_INFO *di, // - dump information const char *kind, // - kind of field const char *name, // - field name target_offset_t offset, // - field offset target_size_t size ) // - field size { di = bufferInit( di ); di = bufferStr( di, kind ); di = bufferChr( di, ' ' ); di = bufferStr( di, name ); di = bufferStr( di, ", offset = " ); di = bufferNmb( di, offset ); di = bufferStr( di, ", size = " ); di = bufferNmb( di, size ); di = bufferWrite( di ); return di; }
static void init(SENSOR* sensor){ GPS_NMEA* gps = (GPS_NMEA*)sensor; // Allocate a buffer for the queued msgs if(gps->msgQueue==null){ size_t space = MAX_NMEA_MSG * 3; // Queue up to 3 messages gps->msgQueue = malloc(space); // Allocate space bufferInit(&gps->msgQueueBuf,gps->msgQueue,space); // Initialise queue buffer } // Allocate a buffer for the msg if(gps->msg==null){ gps->msg = malloc(MAX_NMEA_MSG); __uartAttach(gps->uart,&handler, gps); _uartInit(gps->uart, gps->baudRate); // __uartFlushReceiveBuffer(gps->uart); #ifdef DEBUG PRINTF(stdout,"Start monitoring GPS\n"); #endif } }
/** * @brief Main routine for SPI example * @return Does not return */ int main(void) { uint16_t seed = 0; SystemCoreClockUpdate(); Board_Init(); /* SPI initialization */ Init_SPI_PinMux(); /* Initialize stopwatch driver so some event times can be measured */ StopWatch_Init(); /* Setup SPI controllers */ setupMaster(); setupSlave(); /* Enable SPI controller interrupts */ NVIC_EnableIRQ(LPC_SPIMASTERIRQNUM); NVIC_EnableIRQ(LPC_SPISLAVEIRQNUM); DEBUGSTR("SPI master/slave combined example\r\n"); /* If you enable loopback mode and connect the master and slave controller's clock and SSEL lines together, the master and slave will wrap data to each other */ // Chip_SPIM_EnableLoopBack(LPC_SPIMASTERPORT); /* Loop forever */ while (1) { /* Setup some data for transmit from master to slave and slave to master */ seed = bufferInit(seed); /* Set slave transfer, this is only the initial transfer, the callbacks can change this later */ spiSlaveXfer.pTXData16 = slaveTXBuffer16; spiSlaveXfer.txCount = sizeof(slaveTXBuffer16) / sizeof(uint16_t); /* Count is in transfer size */ spiSlaveXfer.pRXData16 = slaveRXBuffer16; spiSlaveXfer.rxCount = sizeof(slaveRXBuffer16) / sizeof(uint16_t); /* Count is in transfer size */ /* Set master transfer, this is only the initial transfer, the callbacks can change this later */ spiMasterXfer.pTXData16 = masterTXBuffer16; /* Use NULL to send 0x0 */ spiMasterXfer.txCount = sizeof(masterTXBuffer16) / sizeof(uint16_t);/* Count is in transfer size */ spiMasterXfer.pRXData16 = masterRXBuffer16; spiMasterXfer.rxCount = sizeof(masterRXBuffer16) / sizeof(uint16_t);/* Count is in transfer size */ /* Setup master transfer options - 16 data bits per transfer, EOT, EOF */ spiMasterXfer.options = SPI_TXCTL_FLEN(16) | /* This must be enabled as a minimum, use 16 data bits */ // SPI_TXCTL_EOT | /* Enable this to assert and deassert SSEL for each individual byte/word, current slave functions for this example do not support this */ // SPI_TXCTL_EOF | /* Insert a delay between bytes/words as defined by frame delay time */ // SPI_TXCTL_RXIGNORE | /* Enable this to ignore incoming data, or set spiMasterXfer.pRXData16 to NULL to ignore RX data */ 0; /* Transfer will terminate after current buffer is sent. If terminate is not set, the buffers must be setup by the callbacks */ spiMasterXfer.terminate = true; /* Use SPI select 0 */ spiMasterXfer.sselNum = 0; /* Time master and slave transfers */ masterTime = StopWatch_Start(); /* Limitation: The call below 'pre-buffers' the initial slave transmit datum. If this isn't pre-buffered, a slave transmit underflow will always occur at slave assertion time for the initial transmit datum. The datum sent to the master will be 0. This is ok as we are only using a single slave, but with multiple slaves pre-buffering is not always an option and the master might need to toss the first byte. */ Chip_SPI_FlushFifos(LPC_SPIMASTERPORT); Chip_SPI_FlushFifos(LPC_SPISLAVEPORT); Chip_SPIS_PreBuffSlave(LPC_SPISLAVEPORT, &spiSlaveXfer); /* Start master transfer */ Chip_SPIM_Xfer(LPC_SPIMASTERPORT, &spiMasterXfer); /* Sleep until transfers are complete */ mEnd = sEnd = false; while ((mEnd == false) || (sEnd == false)) { __WFI(); } /* Toggle LED */ Board_LED_Toggle(0); /* Display some information about the transfer */ Print_Val("\r\nTRANSFER COMPLETE: errors = 0x", errors); errors = 0; Print_Val("Master total transfer time in uS: 0x", StopWatch_TicksToUs(StopWatch_Elapsed(masterTime))); /* Show data */ showData("Master TX data", masterTXBuffer16); showData("Master RX data", masterRXBuffer16); showData("Slave TX data", slaveTXBuffer16); showData("Slave RX data", slaveRXBuffer16); } }
//! create and initialize the uart buffers void uartswInitBuffers(void) { // initialize the UART receive buffer bufferInit(&uartswRxBuffer, uartswRxData, UARTSW_RX_BUFFER_SIZE); }
void uart_init(){ bufferInit(&uart_TxBuf,uart_TxBufferMemory,uart_TxBufferMemorySize); //Initialize TX buffer bufferInit(&uart_RxBuf,uart_RxBufferMemory,uart_RxBufferMemorySize); //Initialize RX buffer printf(deviceMessage); }
void InitFsmSpeaker(void) { bufferInit(&speakerBuffer, speakerBuffer_, sizeof(speakerBuffer_)); }
/** * @brief Application main function * @return Does not return * @note This function will not return */ int main(void) { uint32_t i; uint8_t repeat_num = UART_TEST_REPEAT_NUMBER; volatile int j = 1; uint8_t ch = 0; uint32_t IntStatus; /* Generic Initialization */ Board_Init(); Board_LED_Set(0, false); /* Disable UART1 IRQ */ NVIC_DisableIRQ(UART1_IRQn); /* Initialize the UARTs */ App_UART_Init(LPC_USART0); App_UART_Init(LPC_USART1); /* Custom Initialization */ Chip_UART_IntEnable(LPC_USART1, RXRDY_INT, DISABLE); Chip_UART_IntEnable(LPC_USART1, TXRDY_INT, DISABLE); NVIC_EnableIRQ(UART1_IRQn); /* Data transfer loop */ while (repeat_num--) { bufferInit(repeat_num); /* Sending from UART0 (polling mode) to UART1 (interrupt mode) */ receiveCompleted = false; Chip_UART_IntEnable(LPC_USART1, RXRDY_INT, ENABLE); for (i = 0; i < BUFFER_SIZE; i++) { while (Chip_UART_SendByte(LPC_USART0, TxBuf0[i]) != SUCCESS) {} } while (!receiveCompleted) {} /* Clear Rx FIFO */ Chip_UART_ReceiveByte(LPC_USART0, &ch); /* Sending from UART1 (interrupt mode) to UART0 (polling mode) */ sendCompleted = false; Chip_UART_IntEnable(LPC_USART1, TXRDY_INT, ENABLE); for (i = 0; i < BUFFER_SIZE; i++) { while (Chip_UART_ReceiveByte(LPC_USART0, &RxBuf0[i]) != SUCCESS) {} } while (!sendCompleted) {} bufferCheck(); } NVIC_DisableIRQ(UART1_IRQn); /* Test OK - Turn on Red LED */ Board_LED_Set(0, true); /* Should not return */ while (j) {} return 0; }
int sharedBufferInit(int shmId, Buffer** buffer, int maxSize) { if(sharedBufferAttach(shmId, buffer)) return -1; return bufferInit(*buffer, maxSize, 1); }
/** * Initialize the parser */ NMEAParser::NMEAParser(QObject *parent):GPSParser(parent) { bufferInit(&gpsRxBuffer, (unsigned char *)gpsRxData, 512); gpsRxOverflow=0; }