int main(void) { SysCtlClockSet( SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); UARTStdioConfig(0, 115200, 16000000); ADCSequenceDisable(ADC0_BASE, 1); ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 1); UARTprintf("This is ADC examlpe"); while (1) { UARTprintf("Temperature is: %d \210 C\n", ADC_getVal()); SysCtlDelay(40000000 / 3); } }
/* * ======== EK_LM4F120XL_initSDSPI ======== */ Void EK_LM4F120XL_initSDSPI(Void) { /* Enable the peripherals used by the SD Card */ SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); /* Configure pad settings */ GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_6, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU); GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_5, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB6_SSI2RX); GPIOPinConfigure(GPIO_PB7_SSI2TX); /* * These GPIOs are connected to PB6 and PB7 and need to be brought into a * GPIO input state so they don't interfere with SPI communications. */ GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0); GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1); SDSPI_init(); }
//***************************************************************************** // // This function sets up UART0 to be used for a console to display information // as the example is running. // //***************************************************************************** void InitConsole(void) { // // Enable GPIO port A which is used for UART0 pins. // TODO: change this to whichever GPIO port you are using. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Configure the pin muxing for UART0 functions on port A0 and A1. // 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_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); // // Select the alternate (UART) function for these pins. // TODO: change this to select the port/pin you are using. // GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Initialize the UART for console I/O. // UARTStdioInit(0); }
//Initialize as a slave void TwoWire::begin(uint8_t address) { if(i2cModule == NOT_ACTIVE) { i2cModule = BOOST_PACK_WIRE; } SysCtlPeripheralEnable(g_uli2cPeriph[i2cModule]); GPIOPinConfigure(g_uli2cConfig[i2cModule][0]); GPIOPinConfigure(g_uli2cConfig[i2cModule][1]); GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]); GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]); slaveAddress = address; //Enable slave interrupts IntEnable(g_uli2cInt[i2cModule]); I2CSlaveIntEnableEx(SLAVE_BASE, I2C_SLAVE_INT_DATA | I2C_SLAVE_INT_STOP); HWREG(SLAVE_BASE + I2C_O_SICR) = I2C_SICR_DATAIC | I2C_SICR_STARTIC | I2C_SICR_STOPIC; //Setup as a slave device I2CMasterDisable(MASTER_BASE); I2CSlaveEnable(SLAVE_BASE); I2CSlaveInit(SLAVE_BASE, address); IntMasterEnable(); }
void motors_init(void) { int i; uint8_t pin_mask; uint32_t motor_per; // Set Pins to output/PWM in GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1); GPIOPinConfigure(GPIO_PF2_M1PWM6); GPIOPinConfigure(GPIO_PF3_M1PWM7); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); // Configure the pin for standby control GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6); SysCtlPWMClockSet(SYSCTL_PWMDIV_64); // Configure the PWM for each pin: // Turn on the generators and set the PW to 0 // The output is still OFF. Turn on with set_motor_pwm_state for (i = 0; i < NUM_MOTORS; i++) { PWMGenConfigure(motors[i].pwm_base_module, motors[i].pwm_generator, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); motor_per = calc_cycles(MOTOR_PERIOD); PWMGenPeriodSet(motors[i].pwm_base_module, motors[i].pwm_generator, motor_per); PWMPulseWidthSet(motors[i].pwm_base_module, motors[i].pwm_pin, 0); PWMGenEnable(motors[i].pwm_base_module, motors[i].pwm_generator); pin_mask = 1 << (0x0000000F & motors[i].pwm_pin); PWMOutputState(motors[i].pwm_base_module, pin_mask, 0); } }
/* * ======== LM4F120H5QR_initI2C ======== */ Void EK_LM4F120XL_initI2C(Void) { /* I2C1 Init */ /* Enable the peripheral */ SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); /* Configure the appropriate pins to be I2C instead of GPIO. */ GPIOPinConfigure(GPIO_PA6_I2C1SCL); GPIOPinConfigure(GPIO_PA7_I2C1SDA); GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6); GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7); /* I2C3 Init */ /* Enable the peripheral */ SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3); /* Configure the appropriate pins to be I2C instead of GPIO. */ GPIOPinConfigure(GPIO_PD0_I2C3SCL); GPIOPinConfigure(GPIO_PD1_I2C3SDA); GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0); GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1); /* * These GPIOs are connected to PD0 and PD1 and need to be brought into a * GPIO input state so they don't interfere with I2C communications. */ GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7); I2C_init(); }
void ConfigureUARTSensores() { // // Enable the GPIO Peripheral used by the UART. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // // Enable UART2 // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); // // Configure GPIO Pins for UART mode. // GPIOPinConfigure(GPIO_PC4_U4RX); GPIOPinConfigure(GPIO_PC5_U4TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART4_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART4_BASE, 16000000, SERIAL_SPEED, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART4_BASE); }
int main(void) { uint32_t ui32Index; uint32_t ui32Data; SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA2_SSI0CLK); GPIOPinConfigure(GPIO_PA3_SSI0FSS); GPIOPinConfigure(GPIO_PA5_SSI0TX); GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_2); SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 16); SSIEnable(SSI0_BASE); while(1) { for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++) { ui32Data = (Reverse(pui8DataTx[ui32Index]) << 8) + (1 << ui32Index); SSIDataPut(SSI0_BASE, ui32Data); while(SSIBusy(SSI0_BASE)) { } } } }
void I2C_Init0(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); //reset I2C module SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); //enable GPIO peripheral that contains I2C SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // Configure the pin muxing for I2C0 functions on port B2 and B3. GPIOPinConfigure(GPIO_PB2_I2C0SCL); GPIOPinConfigure(GPIO_PB3_I2C0SDA); // Select the I2C function for these pins. GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); // 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. I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false); //Thrasher - Why was this here? //clear I2C FIFOs //HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000; }
int main() { SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); GPIOPinConfigure(GPIO_PB4_SSI2CLK); GPIOPinConfigure(GPIO_PB7_SSI2TX); GPIOPinTypeSSI(GPIO_PORTB_BASE,GPIO_PIN_4|GPIO_PIN_7); SSIConfigSetExpClk(SSI2_BASE,SysCtlClockGet(),SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,2000000,8); SSIEnable(SSI2_BASE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_2,0); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_3,0); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinWrite(GPIO_PORTB_BASE,GPIO_PIN_6,0); while(1) { SSIDataPut(SSI2_BASE,0xAA); latch(); SysCtlDelay(SysCtlClockGet()/10); SSIDataPut(SSI2_BASE,0x55); latch(); SysCtlDelay(SysCtlClockGet()/10); } }
/****************************************************************************** * UART-0 Configuration VCP (Virtual Com Port) * ---------------------------------------------------------------------------- * UART 0 -> Port A -> Pins PA0(Tx) & PA1(Rx) * 9600-8N1 * ******************************************************************************/ void PSO_UART0Config() { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); /* Enable UART Module 0 */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); /* Enable GPIO Port A for UART-0 use */ GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); 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); /* UART-0 interrupt configuration */ UARTDisable(UART0_BASE); UARTFIFOEnable(UART0_BASE); IntEnable(INT_UART0); UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX7_8); UARTIntEnable(UART0_BASE, UART_INT_RX); // | UART_INT_RT UARTEnable(UART0_BASE); UARTFIFOEnable(UART0_BASE); }
void tm4c129EthInitGpio(NetInterface *interface) { //DK-TM4C129X evaluation board? #if defined(USE_DK_TM4C129X) //Enable GPIO clocks SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); //Select the relevant alternate function for PF1, PK4 and PK6 GPIOPinConfigure(GPIO_PF1_EN0LED2); GPIOPinConfigure(GPIO_PK4_EN0LED0); GPIOPinConfigure(GPIO_PK6_EN0LED1); //Configure Ethernet LED pins for proper operation GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinTypeEthernetLED(GPIO_PORTK_BASE, GPIO_PIN_4 | GPIO_PIN_6); //EK-TM4C1294XL evaluation board? #elif defined(USE_EK_TM4C1294XL) //Enable GPIO clock SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //Select the relevant alternate function for PF0 and PF4 GPIOPinConfigure(GPIO_PF0_EN0LED0); GPIOPinConfigure(GPIO_PF4_EN0LED1); //Configure Ethernet LED pins for proper operation GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4); #endif }
//***************************************************************************** // // Configure the UART and its pins. This must be called before UARTprintf(). // //***************************************************************************** void ConfigureUART(void) { // // Enable the GPIO Peripheral used by the UART. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Enable UART0 // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Configure GPIO Pins for UART mode. // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Use the internal 16MHz oscillator as the UART clock source. // UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); UARTConfigSetExpClk(UART0_BASE, 16000000, SERIAL_SPEED, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTEnable(UART0_BASE); }
//***************************************************************************** // // Print "Hello world!" to the UART on the Stellaris evaluation board. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Initialize the UART. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioInit(0); // // Hello! // UARTprintf("\033[2JHello World!\n"); // // Finished. // while(1) { } }
int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_SYSDIV_5| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS); ADCSequenceStepConfigure(ADC0_BASE,1,3,ADC_CTL_TS|ADC_CTL_IE|ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 1); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); ledPinConfig(); while (1) { Test2(); //print_temc(); SysCtlDelay(SysCtlClockGet()/3); } }
int main(void) { My_Init(); Init_Timer(); Init_I2C(); Init_Sensors(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); ///////////////////////////////// SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //enable GPIO port for LED GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); //enable pin for LED PF2 UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntMasterEnable(); //enable processor interrupts IntEnable(INT_UART0); //enable the UART interrupt UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts ///////////////////////////////// Kalman_Sim_initialize(); while(1) { Read_Accelerometer(); Calculate_Acc(); Read_Compass(); Compass_Heading(); Calculate_Compass(); Read_Gyro(); Calculate_Gyro(); fgyro[0] = sen_data.gyro_x; fgyro[1] = sen_data.gyro_y; fgyro[2] = sen_data.gyro_z; facc[0] = sen_data.accel_x; facc[1] = sen_data.accel_y; facc[2] = sen_data.accel_z; fmag[0] = sen_data.magnetom_x; fmag[1] = sen_data.magnetom_y; fmag[2] = sen_data.magnetom_z; Kalman_Sim_step(); data[0]=Out1[0]; data[1]=Out1[1]; data[2]=Out1[2]; Timer_CyRun(); } }
int rt_hw_luminaryif_init(void) { rt_err_t result; unsigned long ulUser0, ulUser1; /* Enable and Reset the Ethernet Controller. */ SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH); SysCtlPeripheralReset(SYSCTL_PERIPH_ETH); /* Enable Port F for Ethernet LEDs. LED0 Bit 3 Output LED1 Bit 2 Output */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); /* GPIODirModeSet and GPIOPadConfigSet */ GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); GPIOPinConfigure(GPIO_PF2_LED1); GPIOPinConfigure(GPIO_PF3_LED0); FlashUserSet(0x00371200, 0x00563412); /* OUI:00-12-37 (hex) Texas Instruments, only for test */ /* Configure the hardware MAC address */ FlashUserGet(&ulUser0, &ulUser1); if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff)) { rt_kprintf("Fatal error in geting MAC address\n"); } /* init rt-thread device interface */ luminaryif_dev_entry.parent.parent.init = luminaryif_init; luminaryif_dev_entry.parent.parent.open = luminaryif_open; luminaryif_dev_entry.parent.parent.close = luminaryif_close; luminaryif_dev_entry.parent.parent.read = luminaryif_read; luminaryif_dev_entry.parent.parent.write = luminaryif_write; luminaryif_dev_entry.parent.parent.control = luminaryif_control; luminaryif_dev_entry.parent.eth_rx = luminaryif_rx; luminaryif_dev_entry.parent.eth_tx = luminaryif_tx; /* Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC address needed to program the hardware registers, then program the MAC address into the Ethernet Controller registers. */ luminaryif_dev_entry.dev_addr[0] = ((ulUser0 >> 0) & 0xff); luminaryif_dev_entry.dev_addr[1] = ((ulUser0 >> 8) & 0xff); luminaryif_dev_entry.dev_addr[2] = ((ulUser0 >> 16) & 0xff); luminaryif_dev_entry.dev_addr[3] = ((ulUser1 >> 0) & 0xff); luminaryif_dev_entry.dev_addr[4] = ((ulUser1 >> 8) & 0xff); luminaryif_dev_entry.dev_addr[5] = ((ulUser1 >> 16) & 0xff); /* Program the hardware with it's MAC address (for filtering). */ EthernetMACAddrSet(ETH_BASE, luminaryif_dev_entry.dev_addr); rt_sem_init(&tx_sem, "emac", 1, RT_IPC_FLAG_FIFO); result = eth_device_init(&(luminaryif_dev->parent), "E0"); return result; }
/** * usage: this method sets up the environment to make sure the UART interface can be used * @method initializeUART * @author: patrik.szabo * @param *none* * @return *none* */ void initializeUART() { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UART_init(); }
void UART_Init(void){ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(0,BAUD_RATE,50000000); }
void uart1Init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 38400,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); }
void init_uart(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); }
void GPS::Init(){ // Config GPS-side UART SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);// Enable UART hardware SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);// Enable Pin hardware GPIOPinConfigure(GPIO_PC4_U1RX);// Configure GPIO pin for UART RX line GPIOPinConfigure(GPIO_PC5_U1TX);// Configure GPIO Pin for UART TX line GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); // set pins for UART UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); }
/** * In this function, the hardware should be initialized. * Called from stellarisif_init(). * * @param netif the already initialized lwip network interface structure * for this ethernetif */ static void stellarisif_hwinit(struct netif *netif) { u32_t temp; //struct stellarisif *stellarisif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; #if 1 // // Enable the Link OK and Link Activity LEDS. // GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); GPIOPinConfigure(GPIO_PF3_LED0); GPIOPinConfigure(GPIO_PF2_LED1); #endif /* set MAC hardware address */ EthernetMACAddrGet(ETH_BASE, &(netif->hwaddr[0])); /* maximum transfer unit */ netif->mtu = 1500; /* device capabilities */ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP; /* Do whatever else is needed to initialize interface. */ /* Disable all Ethernet Interrupts. */ EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); temp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, temp); /* Initialize the Ethernet Controller. */ EthernetInitExpClk(ETH_BASE, SysCtlClockGet()); /* * Configure the Ethernet Controller for normal operation. * - Enable TX Duplex Mode * - Enable TX Padding * - Enable TX CRC Generation * - Enable RX Multicast Reception */ EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN |ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN)); /* Enable the Ethernet Controller transmitter and receiver. */ EthernetEnable(ETH_BASE); /* Enable the Ethernet Interrupt handler. */ IntEnable(INT_ETH); /* Enable Ethernet TX and RX Packet Interrupts. */ EthernetIntEnable(ETH_BASE, ETH_INT_RX | ETH_INT_TX); }
//***************************************************************************** // // Configure the USB controller and power the bus. // // This function configures the USB controller for host operation. // It is assumed that the main system clock has been configured at this point. // // \return None. // //***************************************************************************** void ConfigureUSBInterface(void) { // // Enable the uDMA controller and set up the control table base. // This is required by usblib. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); uDMAEnable(); uDMAControlBaseSet(g_sDMAControlTable); // // Enable the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); // // Set the USB pins to be controlled by the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); GPIOPinConfigure(GPIO_PH3_USB0EPEN); GPIOPinConfigure(GPIO_PH4_USB0PFLT); ROM_GPIOPinTypeUSBDigital(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_4); // // Register the host class driver // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS); // // Open an instance of the mass storage class driver. // g_ulMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the power configuration. This sets the power enable signal // to be active high and does not enable the power fault. // USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER); // // Set the ID pin to be driven low so that OTG calls are not necessary. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0); // // Wait 10ms for the pin to go low. // SysCtlDelay(SysCtlClockGet()/100); // // Initialize the host controller. // USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE); }
//***************************************************************************** // // Configure the USB controller and power the bus. // // This function configures the USB controller for host operation. // It is assumed that the main system clock has been configured at this point. // // \return None. // //***************************************************************************** void ConfigureUSBInterface(void) { // // Enable the uDMA controller and set up the control table base. // This is required by usblib. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); uDMAEnable(); uDMAControlBaseSet(g_sDMAControlTable); // // Enable the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); // // Set the USB pins to be controlled by the USB controller. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA6_USB0EPEN); GPIOPinConfigure(GPIO_PA7_USB0PFLT); ROM_GPIOPinTypeUSBDigital(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7); // // Register the host class driver // USBHCDRegisterDrivers(0, g_ppHostClassDrivers, NUM_CLASS_DRIVERS); // // Open an instance of the mass storage class driver. // g_ulMSCInstance = USBHMSCDriveOpen(0, MSCCallback); // // Initialize the power configuration. This sets the power enable signal // to be active high and does not enable the power fault. // USBHCDPowerConfigInit(0, USBHCD_VBUS_AUTO_HIGH | USBHCD_VBUS_FILTER); // // Force the USB mode to host with no callback on mode changes since // there should not be any. // USBStackModeSet(0, USB_MODE_FORCE_HOST, 0); // // Wait 10ms for the pin to go low. // SysCtlDelay(SysCtlClockGet()/100); // // Initialize the host controller. // USBHCDInit(0, g_pHCDPool, HCD_MEMORY_SIZE); }
int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enable the GPIO A ports SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Enable the GPIO E ports SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); GPIOPinConfigure(GPIO_PB6_M0PWM0); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinConfigure(GPIO_PB7_M0PWM1); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 6400000); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_0) / 1.25); PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMGenConfigure(PWM0_BASE, PWM_GEN_1, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_1, 6400000); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, PWMGenPeriodGet(PWM0_BASE, PWM_GEN_1) / 1.25); PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_1); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6|GPIO_PIN_7); // Set pin 7 as the output port GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_1|GPIO_PIN_2); GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_5); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7 GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4); while(1) { GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,64); // Give '1' to pin 7 GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,4); SysCtlDelay(4000000*10); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7 GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32); SysCtlDelay(400000); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,128); // Give '1' to pin 7 GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,2); SysCtlDelay(4000000*10); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_6|GPIO_PIN_7,0); // Give '1' to pin 7 GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2,0); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,32); SysCtlDelay(400000); GPIOPinWrite(GPIO_PORTA_BASE,GPIO_PIN_5,0); } }
//***************************************************************************** // // PoC2Repeater // //***************************************************************************** int main(void) { // Set the clocking to run directly from the crystal at 120MHz. g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // Enable the peripherals ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // Enable the GPIO pins for the LEDs (PN0 and PN1). ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4); // ButtonsInit ROM_GPIODirModeSet(GPIO_PORTJ_BASE, ALL_BUTTONS, GPIO_DIR_MODE_IN); MAP_GPIOPadConfigSet(GPIO_PORTJ_BASE, ALL_BUTTONS, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Enable processor interrupts. ROM_IntMasterEnable(); // Set GPIO PC4 and PC5 as UART pins. GPIOPinConfigure(GPIO_PC4_U7RX); GPIOPinConfigure(GPIO_PC5_U7TX); ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); // Configure the UART for 115,200, 8-N-1 operation. ROM_UARTConfigSetExpClk(UART7_BASE, g_ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Enable the UART interrupt. ROM_IntEnable(INT_UART7); ROM_UARTIntEnable(UART7_BASE, UART_INT_RX | UART_INT_RT); // Reset message info for(uint8_t i = 0; i < MSG; i++) message[i] = 0; // Loop forever echoing data through the UART. while(1) { } }
void uart5Init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinConfigure(GPIO_PE4_U5RX); GPIOPinConfigure(GPIO_PE5_U5TX); GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5); UARTConfigSetExpClk(UART5_BASE, SysCtlClockGet(), 38400,(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntEnable(INT_UART5); UARTIntEnable(UART5_BASE, UART_INT_RX); }
void LCD_Init(void){ Nokia5110_Init(); Nokia5110_Clear(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(0,115200,50000000); }
void setup(){ Serial.begin(9600); Serial.println("DEBUG1"); SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0); SysCtlPeripheralEnable(GPIO_PORTE_BASE); GPIOPinTypeCAN(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5); GPIOPinConfigure(GPIO_PE4_CAN0RX); GPIOPinConfigure(GPIO_PE5_CAN0TX); tCANMsgObject sCANMessage; uint8_t ucMsgData[8]; Serial.println("DEBUG2"); uint8_t pui8BufferIn[8]; uint8_t pui8BufferOut[8]; Serial.println("DEBUG3"); CANInit(CAN0_BASE); CANBitRateSet(CAN0_BASE, SysCtlClockGet(), 500000); CANEnable(CAN0_BASE); sCANMessage.ui32MsgID = 0; // CAN msg ID - 0 for any sCANMessage.ui32MsgIDMask = 0; // mask is 0 for any ID sCANMessage.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER; sCANMessage.ui32MsgLen = 8; // allow up to 8 bytes // // Now load the message object into the CAN peripheral. Once loaded the // CAN will receive any message on the bus, and an interrupt will occur. // Use message object 1 for receiving messages (this is not the same as // the CAN ID which can be any value in this example). // CANMessageSet(CAN0_BASE, 1, &sCANMessage, MSG_OBJ_TYPE_RX); Serial.println("DEBUG5"); while((CANStatusGet(CAN0_BASE, CAN_STS_NEWDAT) & 1) == 0) { // // Read the message out of the message object. // CANMessageGet(CAN0_BASE, 1, &sCANMessage, true); Serial.println(sCANMessage.ui32MsgLen); } Serial.println(sCANMessage.ui32MsgLen); Serial.println(sCANMessage.ui32MsgID); }