本文整理汇总了C++中SysCtlClockGet函数的典型用法代码示例。如果您正苦于以下问题:C++ SysCtlClockGet函数的具体用法?C++ SysCtlClockGet怎么用?C++ SysCtlClockGet使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SysCtlClockGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stepper_set_stepping_rate
void stepper_set_stepping_rate(struct stepper *s, uint32_t stepping_rate){
s->stepping_rate = stepping_rate;
TimerLoadSet(TIMER2_BASE, TIMER_A, SysCtlClockGet()/(s->stepping_rate * (256 / s->div)));
}
示例2: main
//*****************************************************************************
//
// Configure the CAN and enter a loop to transmit periodic CAN messages.
//
//*****************************************************************************
int
main(void)
{
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for CAN operation.
//
InitConsole();
//
// For this example CAN0 is used with RX and TX pins on port D0 and D1.
// The actual port and pins used may be different on your part, consult
// the data sheet for more information.
// GPIO port D needs to be enabled so these pins can be used.
// TODO: change this to whichever GPIO port you are using
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// Configure the GPIO pin muxing to select CAN0 functions for these pins.
// This step selects which alternate function is available for these pins.
// This is necessary if your part supports GPIO pin function muxing.
// Consult the data sheet to see which functions are allocated per pin.
// TODO: change this to select the port/pin you are using
//
GPIOPinConfigure(GPIO_PD0_CAN0RX);
GPIOPinConfigure(GPIO_PD1_CAN0TX);
//
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
// TODO: change this to match the port/pin you are using
//
GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
//
// Initialize the CAN controller
//
CANInit(CAN0_BASE);
//
// Set up the bit rate for the CAN bus. This function sets up the CAN
// bus timing for a nominal configuration. You can achieve more control
// over the CAN bus timing by using the function CANBitTimingSet() instead
// of this one, if needed.
// In this example, the CAN bus is set to 500 kHz. In the function below,
// the call to SysCtlClockGet() is used to determine the clock rate that
// is used for clocking the CAN peripheral. This can be replaced with a
// fixed value if you know the value of the system clock, saving the extra
// function call. For some parts, the CAN peripheral is clocked by a fixed
// 8 MHz regardless of the system clock in which case the call to
// SysCtlClockGet() should be replaced with 8000000. Consult the data
// sheet for more information about CAN peripheral clocking.
//
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);
//
// Enable interrupts on the CAN peripheral. This example uses static
// allocation of interrupt handlers which means the name of the handler
// is in the vector table of startup code. If you want to use dynamic
// allocation of the vector table, then you must also call CANIntRegister()
// here.
//
// CANIntRegister(CAN0_BASE, CANIntHandler); // if using dynamic vectors
//
CANIntEnable(CAN0_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
//
// Enable the CAN interrupt on the processor (NVIC).
//
IntEnable(INT_CAN0);
//
// Enable the CAN for operation.
//
CANEnable(CAN0_BASE);
//
// Initialize the message object that will be used for sending CAN
// messages. The message will be 4 bytes that will contain an incrementing
//.........这里部分代码省略.........
示例3: main
//*****************************************************************************
//
// Configure the CAN and enter a loop to receive CAN messages.
//
//*****************************************************************************
int
main(void)
{
#if defined(TARGET_IS_TM4C129_RA0) || \
defined(TARGET_IS_TM4C129_RA1) || \
defined(TARGET_IS_TM4C129_RA2)
uint32_t ui32SysClock;
#endif
tCANMsgObject sCANMessage;
uint8_t pui8MsgData[8];
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal used on your board.
//
#if defined(TARGET_IS_TM4C129_RA0) || \
defined(TARGET_IS_TM4C129_RA1) || \
defined(TARGET_IS_TM4C129_RA2)
ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN |
SYSCTL_USE_OSC)
25000000);
#else
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
#endif
//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for CAN operation.
//
InitConsole();
//
// For this example CAN0 is used with RX and TX pins on port B4 and B5.
// The actual port and pins used may be different on your part, consult
// the data sheet for more information.
// GPIO port B needs to be enabled so these pins can be used.
// TODO: change this to whichever GPIO port you are using
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Configure the GPIO pin muxing to select CAN0 functions for these pins.
// This step selects which alternate function is available for these pins.
// This is necessary if your part supports GPIO pin function muxing.
// Consult the data sheet to see which functions are allocated per pin.
// TODO: change this to select the port/pin you are using
//
GPIOPinConfigure(GPIO_PB4_CAN0RX);
GPIOPinConfigure(GPIO_PB5_CAN0TX);
//
// Enable the alternate function on the GPIO pins. The above step selects
// which alternate function is available. This step actually enables the
// alternate function instead of GPIO for these pins.
// TODO: change this to match the port/pin you are using
//
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5);
//
// The GPIO port and pins have been set up for CAN. The CAN peripheral
// must be enabled.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
//
// Initialize the CAN controller
//
CANInit(CAN0_BASE);
//
// Set up the bit rate for the CAN bus. This function sets up the CAN
// bus timing for a nominal configuration. You can achieve more control
// over the CAN bus timing by using the function CANBitTimingSet() instead
// of this one, if needed.
// In this example, the CAN bus is set to 500 kHz. In the function below,
// the call to SysCtlClockGet() or ui32SysClock is used to determine the
// clock rate that is used for clocking the CAN peripheral. This can be
// replaced with a fixed value if you know the value of the system clock,
// saving the extra function call. For some parts, the CAN peripheral is
// clocked by a fixed 8 MHz regardless of the system clock in which case
// the call to SysCtlClockGet() or ui32SysClock should be replaced with
// 8000000. Consult the data sheet for more information about CAN
// peripheral clocking.
//
#if defined(TARGET_IS_TM4C129_RA0) || \
defined(TARGET_IS_TM4C129_RA1) || \
defined(TARGET_IS_TM4C129_RA2)
CANBitRateSet(CAN0_BASE, ui32SysClock, 500000);
#else
CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000);
#endif
//.........这里部分代码省略.........
示例4: main
//*****************************************************************************
//
// Configure SSI0 in master Freescale (SPI) mode. This example will send out
// 3 bytes of data, then wait for 3 bytes of data to come in. This will all be
// done using the polling method.
//
//*****************************************************************************
int
main(void)
{
unsigned long ulDataTx[NUM_SSI_DATA];
unsigned long ulDataRx[NUM_SSI_DATA];
unsigned long ulindex;
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for SSI operation.
//
InitConsole();
//
// Display the setup on the console.
//
UARTprintf("SSI ->\n");
UARTprintf(" Mode: SPI\n");
UARTprintf(" Data: 8-bit\n\n");
//
// The SSI0 peripheral must be enabled for use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
//
// For this example SSI0 is used with PortA[5:2]. The actual port and pins
// used may be different on your part, consult the data sheet for more
// information. GPIO port A needs to be enabled so these pins can be used.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);
//
// Configure the GPIO settings for the SSI pins. This function also gives
// control of these pins to the SSI hardware. Consult the data sheet to
// see which functions are allocated per pin.
// The pins are assigned as follows:
// PA5 - SSI0Tx
// PA4 - SSI0Rx
// PA3 - SSI0Fss
// PA2 - SSI0CLK
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 |
GPIO_PIN_2);
//
// Configure and enable the SSI port for SPI master mode. Use SSI0,
// system clock supply, idle clock level low and active low clock in
// freescale SPI mode, master mode, 1MHz SSI frequency, and 8-bit data.
// For SPI mode, you can set the polarity of the SSI clock when the SSI
// unit is idle. You can also configure what clock edge you want to
// capture data on. Please reference the datasheet for more information on
// the different SPI modes.
//
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 1000000, 8);
//
// Enable the SSI0 module.
//
SSIEnable(SSI0_BASE);
//
// Read any residual data from the SSI port. This makes sure the receive
// FIFOs are empty, so we don't read any unwanted junk. This is done here
// because the SPI SSI mode is full-duplex, which allows you to send and
// receive at the same time. The SSIDataGetNonBlocking function returns
// "true" when data was returned, and "false" when no data was returned.
// The "non-blocking" function checks if there is any data in the receive
// FIFO and does not "hang" if there isn't.
//
while(SSIDataGetNonBlocking(SSI0_BASE, &ulDataRx[0]))
{
//.........这里部分代码省略.........
示例5: Systick_Init
void Systick_Init(void)
{
/* 1ms */
SysTick_Config((SysCtlClockGet()/1000));
}
示例6: I2CSetup
//*****************************************************************************
//
//! Initializes and enables the specified I2C block.
//!
//! \param ulI2CBase is the I2C peripheral to be used.
//! \param ulI2CSpeed defines the normal (100kbps) or fast (400kbps) I2C mode.
//!
//! This function enables the specified I2C block and sets it up to run at
//! the either 100kbps or 400kbps. If the \e ulI2CSpeed is false, the I2C will
//! run at 100kbps and if true, then the I2C will run at 400kbps. The
//! \e ulI2CBase parameter can be one of the following values:
//!
//! - \b I2C0_MASTER_BASE
//! - \b I2C1_MASTER_BASE
//! - \b I2C2_MASTER_BASE
//! - \b I2C3_MASTER_BASE
//!
//! \return None.
//
//*****************************************************************************
void I2CSetup(unsigned long ulI2CBase, unsigned long ulI2CSpeed)
{
//
// Check the arguments.
//
ASSERT(I2CMasterBaseValid(ulI2CBase));
ASSERT((ulI2CSpeed == true) || (ulI2CSpeed == false));
switch (ulI2CBase)
{
// I2C_PERIPH_0
case I2C0_MASTER_BASE:
//
// I2C0 is used with PortB[3:2]. The actual port and
// pins used may be different on your part, consult the data sheet for
// more information. GPIO port B needs to be enabled so these pins can
// be used.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Select the I2C function for these pins. This function will also
// configure the GPIO 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_PORTB_BASE, GPIO_PIN_2); // special I2CSCL treatment for M4F devices
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
//
// Configure the pin muxing for I2C0 functions on port B2 and B3.
// This step is not necessary if your part does not support pin muxing.
//
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
//
// The I2C0 peripheral must be enabled before use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
//
// Enable and initialize the I2C0 master module.
//
I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), ulI2CSpeed);
break;
// I2C_PERIPH_1
case I2C1_MASTER_BASE:
//
// I2C1 is used with PortA[7:6]. The actual port and
// pins used may be different on your part, consult the data sheet for
// more information. GPIO port A needs to be enabled so these pins can
// be used.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Select the I2C function for these pins. This function will also
// configure the GPIO 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_PORTA_BASE, GPIO_PIN_6); // special I2CSCL treatment for M4F devices
GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
//
// Configure the pin muxing for I2C1 functions on port A6 and A7.
// This step is not necessary if your part does not support pin muxing.
//
GPIOPinConfigure(GPIO_PA6_I2C1SCL);
GPIOPinConfigure(GPIO_PA7_I2C1SDA);
//
// The I2C1 peripheral must be enabled before use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
//
// Enable and initialize the I2C1 master module.
//.........这里部分代码省略.........
示例7: readSensorData
void readSensorData(GameState* state) {
short dataX;
short dataY;
short dataZ;
char printVal[10];
char chPwrCtlReg = 0x2D;
char chX0Addr = 0x32;
char chY0Addr = 0x34;
char chZ0Addr = 0x36;
char rgchReadAccl[] = {
0, 0, 0 };
char rgchWriteAccl[] = {
0, 0 };
char rgchReadAccl2[] = {
0, 0, 0 };
char rgchReadAccl3[] = {
0, 0, 0 };
int xDirThreshPos = 50;
int xDirThreshNeg = -50;
bool fDir = true;
if(state->accelInitialized == 0){
/*
* Enable I2C Peripheral
*/
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
/*
* Set I2C GPIO pins
*/
GPIOPinTypeI2C(I2CSDAPort, I2CSDA_PIN);
GPIOPinTypeI2CSCL(I2CSCLPort, I2CSCL_PIN);
GPIOPinConfigure(I2CSCL);
GPIOPinConfigure(I2CSDA);
/*
* Setup I2C
*/
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
/* Initialize the Accelerometer
*
*/
GPIOPinTypeGPIOInput(ACCL_INT2Port, ACCL_INT2);
rgchWriteAccl[0] = chPwrCtlReg;
rgchWriteAccl[1] = 1 << 3; // sets Accl in measurement mode
I2CGenTransmit(rgchWriteAccl, 1, WRITE, ACCLADDR);
state->accelInitialized = 1;
}
rgchReadAccl[0] = chX0Addr;
rgchReadAccl2[0] = chY0Addr;
rgchReadAccl3[0] = chZ0Addr;
I2CGenTransmit(rgchReadAccl, 2, READ, ACCLADDR);
I2CGenTransmit(rgchReadAccl2, 2, READ, ACCLADDR);
I2CGenTransmit(rgchReadAccl3, 2, READ, ACCLADDR);
dataX = (rgchReadAccl[2] << 8) | rgchReadAccl[1];
dataY = (rgchReadAccl2[2] << 8) | rgchReadAccl2[1];
dataZ = (rgchReadAccl3[2] << 8) | rgchReadAccl2[1];
state->accelY = dataY;
}
示例8: main
//*****************************************************************************
//
// Configure the I2C0 master and slave and connect them using loopback mode.
//
//*****************************************************************************
int
main(void)
{
uint32_t ui32DataTx;
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// The I2C0 peripheral must be enabled before use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
//
// For this example I2C0 is used with PortB[3:2]. The actual port and
// pins used may be different on your part, consult the data sheet for
// more information. GPIO port B needs to be enabled so these pins can
// be used.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Configure the pin muxing for I2C0 functions on port B2 and B3.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
//
// 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.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
//
// Enable loopback mode. Loopback mode is a built in feature that helps
// for debug the I2Cx module. It internally connects the I2C master and
// slave terminals, which effectively lets you send data as a master and
// receive data as a slave. NOTE: For external I2C operation you will need
// to use external pull-ups that are faster than the internal pull-ups.
// Refer to the datasheet for more information.
//
HWREG(I2C0_BASE + I2C_O_MCR) |= 0x01;
//
// Enable the I2C0 interrupt on the processor (NVIC).
//
IntEnable(INT_I2C0);
//
// Configure and turn on the I2C0 slave interrupt. The I2CSlaveIntEnableEx()
// gives you the ability to only enable specific interrupts. For this case
// we are only interrupting when the slave device receives data.
//
I2CSlaveIntEnableEx(I2C0_BASE, I2C_SLAVE_INT_DATA);
//
// Enable and initialize the I2C0 master module. Use the system clock for
// the I2C0 module. The last parameter sets the I2C data transfer rate.
// If false the data rate is set to 100kbps and if true the data rate will
// be set to 400kbps. For this example we will use a data rate of 100kbps.
//
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
//
// Enable the I2C0 slave module.
//
I2CSlaveEnable(I2C0_BASE);
//
// Set the slave address to SLAVE_ADDRESS. In loopback mode, it's an
// arbitrary 7-bit number (set in a macro above) that is sent to the
// I2CMasterSlaveAddrSet function.
//
I2CSlaveInit(I2C0_BASE, SLAVE_ADDRESS);
//
// Tell the master module what address it will place on the bus when
// communicating with the slave. Set the address to SLAVE_ADDRESS
// (as set in the slave module). The receive parameter is set to false
// which indicates the I2C Master is initiating a writes to the slave. If
// true, that would indicate that the I2C Master is initiating reads from
// the slave.
//
//.........这里部分代码省略.........
示例9: main
//*****************************************************************************
//
// Configure the I2C0 master and slave and connect them using loopback mode.
//
//*****************************************************************************
int
main(void)
{
unsigned long ulDataTx[NUM_I2C_DATA];
unsigned long ulDataRx[NUM_I2C_DATA];
unsigned long ulindex;
//
// Set the clocking to run directly from the external crystal/oscillator.
// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
// crystal on your board.
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
//
// The I2C0 peripheral must be enabled before use.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
//
// For this example I2C0 is used with PortB[3:2]. The actual port and
// pins used may be different on your part, consult the data sheet for
// more information. GPIO port B needs to be enabled so these pins can
// be used.
// TODO: change this to whichever GPIO port you are using.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Configure the pin muxing for I2C0 functions on port B2 and B3.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
//
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
//
// 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.
// TODO: change this to select the port/pin you are using.
//
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);
//
// Enable loopback mode. Loopback mode is a built in feature that is
// useful for debugging I2C operations. It internally connects the I2C
// master and slave terminals, which effectively let's you send data as
// a master and receive data as a slave.
// NOTE: For external I2C operation you will need to use external pullups
// that are stronger than the internal pullups. Refer to the datasheet for
// more information.
//
HWREG(I2C0_MASTER_BASE + I2C_O_MCR) |= 0x01;
//
// Enable and initialize the I2C0 master module. Use the system clock for
// the I2C0 module. The last parameter sets the I2C data transfer rate.
// If false the data rate is set to 100kbps and if true the data rate will
// be set to 400kbps. For this example we will use a data rate of 100kbps.
//
I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), false);
//
// Enable the I2C0 slave module. This module is enabled only for testing
// purposes. It does not need to be enabled for proper operation of the
// I2Cx master module.
//
I2CSlaveEnable(I2C0_SLAVE_BASE);
//
// Set the slave address to SLAVE_ADDRESS. In loopback mode, it's an
// arbitrary 7-bit number (set in a macro above) that is sent to the
// I2CMasterSlaveAddrSet function.
//
I2CSlaveInit(I2C0_SLAVE_BASE, SLAVE_ADDRESS);
//
// Tell the master module what address it will place on the bus when
// communicating with the slave. Set the address to SLAVE_ADDRESS
// (as set in the slave module). The receive parameter is set to false
// which indicates the I2C Master is initiating a writes to the slave. If
// true, that would indicate that the I2C Master is initiating reads from
// the slave.
//
I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, SLAVE_ADDRESS, false);
//
// Set up the serial console to use for displaying messages. This is
// just for this example program and is not needed for I2C operation.
//
InitConsole();
//.........这里部分代码省略.........
示例10: main
//.........这里部分代码省略.........
// source and don't put it in the string table, we run the risk of having
// characters missing in the font.
//
GrStringGet(STR_ENGLISH, g_pcEnglish, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_DEUTSCH, g_pcDeutsch, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_ESPANOL, g_pcEspanol, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_ITALIANO, g_pcItaliano, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_CHINESE, g_pcChinese, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_KOREAN, g_pcKorean, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_JAPANESE, g_pcJapanese, MAX_LANGUAGE_NAME_LEN);
GrStringGet(STR_PLUS, g_pcPlus, 2);
GrStringGet(STR_MINUS, g_pcMinus, 2);
//
// Put the application name in the middle of the banner.
//
GrStringGet(STR_APPNAME, g_pcBuffer, SCOMP_MAX_STRLEN);
GrContextFontSet(&sContext, FONT_20PT);
GrStringDrawCentered(&sContext, g_pcBuffer, -1,
GrContextDpyWidthGet(&sContext) / 2, 10, 0);
//
// Initialize the sound driver.
//
SoundInit();
//
// Initialize the touch screen driver and have it route its messages to the
// widget tree.
//
TouchScreenInit();
TouchScreenCallbackSet(WidgetPointerMessage);
//
// Add the title block and the previous and next buttons to the widget
// tree.
//
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext);
//
// Add the first panel to the widget tree.
//
g_ulPanel = 0;
WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels);
//
// Set the string for the title.
//
CanvasTextSet(&g_sTitle, g_pcTitle);
//
// Initialize the pointer to the button text.
//
PushButtonTextSet(&g_sFirmwareUpdateBtn, g_pcUpdateButton);
//
// Issue the initial paint request to the widgets.
//
WidgetPaint(WIDGET_ROOT);
//
// Loop forever unless we receive a signal that a firmware update has been
// requested.
//
while(!g_bFirmwareUpdate)
{
//
// Process any messages in the widget message queue.
//
WidgetMessageQueueProcess();
}
//
// If we drop out, a firmware update request has been made. We call
// WidgetMessageQueueProcess once more to ensure that any final messages
// are processed then jump into the bootloader.
//
WidgetMessageQueueProcess();
//
// Wait a while for the last keyboard click sound to finish. This is about
// 500mS since the delay loop is 3 cycles long.
//
SysCtlDelay(SysCtlClockGet() / 6);
//
// Pass control to the bootloader.
//
JumpToBootLoader();
//
// The boot loader should take control, so this should never be reached.
// Just in case, loop forever.
//
while(1)
{
}
}
示例11: sys_cfg_uart
/*
* portno从0开始编号
*/
sys_cfg_err_t sys_cfg_uart(struct uart_param *cfgdata, int portno)
{
unsigned long base;
unsigned long cfg;
/* portno, cfgdata->databits, cfgdata->stopbits, cfgdata->paritybit */
if (portno>=UART_PORT_NUM || NULL==cfgdata) {
return SYS_CFG_PARAM_ERR;
}
/* 对波特率进行检查的代码还未编写!!! */
if (cfgdata->databits < UART_DATA_BITS_MIN
|| cfgdata->databits > UART_DATA_BITS_MAX
|| cfgdata->stopbits < UART_STOP_BITS_MIN
|| cfgdata->stopbits > UART_STOP_BITS_MIN) {
return SYS_CFG_DATA_ERR;
}
switch (portno) {
case 0:
base = UART0_BASE;
break;
case 1:
base = UART1_BASE;
break;
case 2: /* UART_PORT_NUM - 1 */
base = UART2_BASE;
break;
default: /* 这种情况不应该出现, 现在只是做简单的处理 */
return SYS_CFG_PARAM_ERR;
}
cfg = 0;
switch (cfgdata->databits) {
case 5: /* UART_DATA_BITS_MIN */
cfg |= UART_CONFIG_WLEN_5;
break;
case 6:
cfg |= UART_CONFIG_WLEN_6;
break;
case 7:
cfg |= UART_CONFIG_WLEN_7;
break;
case 8: /* UART_DATA_BITS_MAX */
cfg |= UART_CONFIG_WLEN_8;
break;
default: /* 这种情况不应该出现, 现在只是做简单的处理 */
return SYS_CFG_PARAM_ERR;
}
if (1 == cfgdata->stopbits)
cfg |= UART_CONFIG_STOP_ONE;
else if (2 == cfgdata->stopbits)
cfg |= UART_CONFIG_STOP_TWO;
else
return SYS_CFG_PARAM_ERR;
switch (cfgdata->paritybit) {
case UART_PAR_NONE:
cfg |= UART_CONFIG_PAR_NONE;
break;
case UART_PAR_EVEN:
cfg |= UART_CONFIG_PAR_EVEN;
break;
case UART_PAR_ODD:
cfg |= UART_CONFIG_PAR_ODD;
break;
case UART_PAR_ONE:
cfg |= UART_CONFIG_PAR_ONE;
break;
case UART_PAR_ZERO:
cfg |= UART_CONFIG_PAR_ZERO;
break;
default:
return SYS_CFG_PARAM_ERR;
}
// Configure the UART for 115,200, 8-N-1 operation.
// This function uses SysCtlClockGet() to get the system clock
// frequency. This could be also be a variable or hard coded value
// instead of a function call.
UARTConfigSetExpClk(base, SysCtlClockGet(), cfgdata->baudrate, cfg);
return SYS_CFG_SUCC;
}
示例12: TouchScreenInit
//*****************************************************************************
//
//! Initializes the touch screen driver.
//!
//! This function initializes the touch screen driver, beginning the process of
//! reading from the touch screen. This driver uses the following hardware
//! resources:
//!
//! - ADC sample sequence 3
//! - Timer 0 subtimer A
//!
//! \return None.
//
//*****************************************************************************
void
TouchScreenInit(void)
{
unsigned short usController;
//
// Set the initial state of the touch screen driver's state machine.
//
g_ulTSState = TS_STATE_INIT;
//
// There is no touch screen handler initially.
//
g_pfnTSHandler = 0;
//
// Determine which display controller is in use and, from this, determine
// what the sense of the Y axis must be. The -F03 version of the display
// containing an ILI9320 controller reverses the sense of the Y axis
// relative to the later -F05 and -F02 versions containing ILI9325 and
// ILI9328 controllers respectively.
//
usController = Formike240x320x16_ILI9320ControllerIdGet();
g_bReverseLongAxis = ((usController != 0x9320) ? true : false);
//
// Enable the peripherals used by the touch screen interface.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
//
// Configure the ADC sample sequence used to read the touch screen reading.
//
ADCHardwareOversampleConfigure(ADC0_BASE, 4);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0,
ADC_CTL_CH6 | ADC_CTL_END | ADC_CTL_IE);
ADCSequenceEnable(ADC0_BASE, 3);
//
// Enable the ADC sample sequence interrupt.
//
ADCIntEnable(ADC0_BASE, 3);
IntEnable(INT_ADC0SS3);
//
// Configure the GPIOs used to drive the touch screen layers.
//
GPIOPinTypeGPIOOutput(TS_X_BASE, TS_XP_PIN | TS_XN_PIN);
GPIOPinTypeGPIOOutput(TS_Y_BASE, TS_YP_PIN | TS_YN_PIN);
GPIOPinWrite(TS_X_BASE, TS_XP_PIN | TS_XN_PIN, 0x00);
GPIOPinWrite(TS_Y_BASE, TS_YP_PIN | TS_YN_PIN, 0x00);
//
// See if the ADC trigger timer has been configured, and configure it only
// if it has not been configured yet.
//
if((HWREG(TIMER0_BASE + TIMER_O_CTL) & TIMER_CTL_TAEN) == 0)
{
//
// Configure the timer to trigger the sampling of the touch screen
// every millisecond.
//
TimerConfigure(TIMER0_BASE, (TIMER_CFG_SPLIT_PAIR |
TIMER_CFG_A_PERIODIC |
TIMER_CFG_B_PERIODIC));
TimerLoadSet(TIMER0_BASE, TIMER_A, (SysCtlClockGet() / 1000) - 1);
TimerControlTrigger(TIMER0_BASE, TIMER_A, true);
//
// Enable the timer. At this point, the touch screen state machine
// will sample and run once per millisecond.
//
TimerEnable(TIMER0_BASE, TIMER_A);
}
}
示例13: main
//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
//
// Set the clocking to run directly from the crystal.
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
//
// Initialize the OLED display and write status.
//
RIT128x96x4Init(1000000);
RIT128x96x4StringDraw("UART Echo", 36, 0, 15);
RIT128x96x4StringDraw("Port: Uart 0", 12, 16, 15);
RIT128x96x4StringDraw("Baud: 115,200 bps", 12, 24, 15);
RIT128x96x4StringDraw("Data: 8 Bit", 12, 32, 15);
RIT128x96x4StringDraw("Parity: None", 12, 40, 15);
RIT128x96x4StringDraw("Stop: 1 Bit", 12, 48, 15);
//
// Enable the peripherals used by this example.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable processor interrupts.
//
IntMasterEnable();
//
// Set GPIO A0 and A1 as UART pins.
//
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Configure the UART for 115,200, 8-N-1 operation.
//
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
//
// Enable the UART interrupt.
//
IntEnable(INT_UART0);
UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
//
// Prompt for text to be entered.
//
UARTSend((unsigned char *)"Enter text: ", 12);
//
// Loop forever echoing data through the UART.
//
while(1)
{
}
}
示例14: main
//.........这里部分代码省略.........
UARTprintf("Power on reset. Hibernate not active.\n");
UARTprintf("> ");
g_sAppState.ui32Mode = APP_MODE_NORMAL;
g_sAppState.fColorWheelPos = 0;
g_sAppState.fIntensity = APP_INTENSITY_DEFAULT;
g_sAppState.ui32Buttons = 0;
}
}
else
{
//
// External Pin reset or other reset event occured.
//
UARTprintf("External or other reset\n");
UARTprintf("> ");
//
// Treat this as a cold power up reset without restore from hibernate.
//
g_sAppState.ui32Mode = APP_MODE_NORMAL;
g_sAppState.fColorWheelPos = APP_PI;
g_sAppState.fIntensity = APP_INTENSITY_DEFAULT;
g_sAppState.ui32Buttons = 0;
//
// colors get a default initialization later when we call AppRainbow.
//
}
//
// Initialize clocking for the Hibernate module
//
HibernateEnableExpClk(SysCtlClockGet());
//
// Initialize the RGB LED. AppRainbow typically only called from interrupt
// context. Safe to call here to force initial color update because
// interrupts are not yet enabled.
//
RGBInit(0);
RGBIntensitySet(g_sAppState.fIntensity);
AppRainbow(1);
RGBEnable();
//
// Initialize the buttons
//
ButtonsInit();
//
// Initialize the SysTick interrupt to process colors and buttons.
//
SysTickPeriodSet(SysCtlClockGet() / APP_SYSTICKS_PER_SEC);
SysTickEnable();
SysTickIntEnable();
IntMasterEnable();
//
// spin forever and wait for carriage returns or state changes.
//
while(1)
{
UARTprintf("\n>");
示例15: Startup
void Startup(void) {
//STEP 1: OLED and PWM setup
unsigned long ulPeriod;
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1);
ulPeriod = SysCtlClockGet() / 4000;
PWMGenConfigure(PWM0_BASE, PWM_GEN_0,PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod);
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, ulPeriod / 16);
PWMGenEnable(PWM0_BASE, PWM_GEN_0);
//STEP 3: Button pad setup
TrainState = 0;
GPIOPortIntUnregister(GPIO_PORTE_BASE);
GPIOPortIntRegister(GPIO_PORTE_BASE,IntGPIOe);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, 0xF);
GPIOPadConfigSet(GPIO_PORTE_BASE, 0xF , GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOIntTypeSet(GPIO_PORTE_BASE, 0xF , GPIO_FALLING_EDGE);
GPIOPinIntEnable(GPIO_PORTE_BASE, 0xF );
IntEnable(INT_GPIOE);
IntPrioritySet( INT_UART0, configKERNEL_INTERRUPT_PRIORITY);
//STEP 4: Frequency count setup
tempCount = 0;
frequencyCount = 0;
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_3);
GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
GPIOPortIntUnregister(GPIO_PORTF_BASE);
GPIOPortIntRegister(GPIO_PORTF_BASE,IntGPIOf);
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_RISING_EDGE);
GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_3);
IntEnable(INT_GPIOF);
//IntPrioritySet( INT_GPIOF, 10);
//STEP 5: UART setup
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
IntEnable(INT_UART0);
UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
// IntPrioritySet( INT_UART0, configKERNEL_INTERRUPT_PRIORITY);
//STEP 6: pin setup
/*SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, PORT_DATA);*/
//STEP 7: ADC SETUP
SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
ADCSequenceDisable(ADC0_BASE,0);
ADCSequenceDisable(ADC0_BASE,1);
ADCSequenceDisable(ADC0_BASE,2);
ADCSequenceDisable(ADC0_BASE,3);
GPIOPinTypeADC(ADC0_BASE, 0xF);
ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC0_BASE, 2, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0);
ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC0_BASE, 2, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
ADCSequenceEnable(ADC0_BASE, 0);
ADCSequenceEnable(ADC0_BASE, 1);
ADCSequenceEnable(ADC0_BASE, 2);
ADCSequenceEnable(ADC0_BASE, 3);
ADCIntClear(ADC0_BASE, 0);
ADCIntClear(ADC0_BASE, 1);
ADCIntClear(ADC0_BASE, 2);
ADCIntClear(ADC0_BASE, 3);
ADCIntEnable(ADC0_BASE, 0);
ADCIntEnable(ADC0_BASE, 1);
ADCIntEnable(ADC0_BASE, 2);
ADCIntEnable(ADC0_BASE, 3);
//IntEnable(INT_ADC0);
//IntPrioritySet(INT_ADC, 50);
//IntEnable(INT_ADC0);
//ADCIntClear(ADC0_BASE, 0);
//.........这里部分代码省略.........
开发者ID:taftj,项目名称:ULTIMATE-COSMIC-COMICALLY-BAD-CODE-I-M-SO-SERIOUS-LIKE-YOU-WOULDN-T-EVEN-BELIEVE-,代码行数:101,代码来源:setup.c