void spi_gpio_init(uint8_t int_flag) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //F0-----MISO ----- INPUT ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0); //F1,F2,F3:MOSI,CLK,CSN ----- OUTPUT ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); //CE-----PA6 ----- OUTPUT ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6); //IRQ-----PA7 ----- INPUT ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7); if(int_flag == 1) //开引脚外部中断 { GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_7,GPIO_FALLING_EDGE); GPIOIntEnable(GPIO_PORTA_BASE,GPIO_INT_PIN_7); //打开PA7外部中断进行数据读取 GPIOIntRegister(GPIO_PORTA_BASE, PA7_int_hander);//指定外部中断处理函数 } else { GPIOIntDisable(GPIO_PORTA_BASE,GPIO_INT_PIN_7); } }
void GPIO_Initial(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6); //Laser ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2|GPIO_PIN_4); //预留、吹风机 ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0| \ GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); //振镜Y、X、CLK、SYN ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0|GPIO_PIN_1|\ GPIO_PIN_2|GPIO_PIN_3 | GPIO_PIN_5); //预留、塔灯红、绿、黄、光闸、抽风机 ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|\ GPIO_PIN_3|GPIO_PIN_4); //板上显示灯:红、蓝、绿;LCD复位 ROM_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, \ GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); //冷水机开关信号 ROM_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_6); //测速 ROM_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6); //手动开关、运行模式 HWREG(GPIO_PORTD_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTD_BASE+GPIO_O_CR) |= 0x80; HWREG(GPIO_PORTD_BASE+GPIO_O_AFSEL) &= ~(0x80); HWREG(GPIO_PORTD_BASE+GPIO_O_DEN) |= 0x80; ROM_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_7); HWREG(GPIO_PORTD_BASE+GPIO_O_LOCK) = 0; }
// Fonction qui initialise le LCD void init_lcd(void) { // Enable ports on board ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Configure pins ROM_GPIOPadConfigSet(GPIO_PORTE_BASE, 0xFF, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD); // Enable data as output ROM_GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, 0xFF); // Toutes les pins // Default values of pins to zero ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW | LCD_E, 0x00); ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x00); // Set LCD to 2line mode wait(); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Write); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E); ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x38); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0); // Activate cursor blinking wait(); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_RS | LCD_RW, LCD_RS_Instruction | LCD_RW_Write); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, LCD_E); ROM_GPIOPinWrite(GPIO_PORTE_BASE, 0xFF, 0x0F); ROM_GPIOPinWrite(GPIO_PORTJ_BASE, LCD_E, 0); // Clear LCD clear(); }
static void Config_PWM(void) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_GPIOPinConfigure(GPIO_PB6_T0CCP0); ROM_GPIOPinConfigure(GPIO_PB2_T3CCP0); ROM_GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_6); // Configure timer ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3); ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM); ROM_TimerLoadSet(TIMER0_BASE, TIMER_A, DEFAULT); ROM_TimerMatchSet(TIMER0_BASE, TIMER_A, DEFAULT); // PWM ROM_TimerEnable(TIMER0_BASE, TIMER_A); ROM_TimerConfigure(TIMER3_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PWM); ROM_TimerLoadSet(TIMER3_BASE, TIMER_A, DEFAULT); ROM_TimerMatchSet(TIMER3_BASE, TIMER_A, DEFAULT); // PWM ROM_TimerControlLevel(TIMER3_BASE, TIMER_A, true); ROM_TimerEnable(TIMER3_BASE, TIMER_A); ROM_SysCtlPeripheralEnable(DRV_ENABLE_LEFT_CHN_PERIPHERAL); ROM_SysCtlPeripheralEnable(DRV_ENABLE_RIGHT_CHN_PERIPHERAL); ROM_GPIOPinTypeGPIOOutput(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN); ROM_GPIOPinTypeGPIOOutput(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN); ROM_GPIOPinWrite(DRV_ENABLE_LEFT_CHN_PORT, DRV_ENABLE_LEFT_CHN_PIN, 0); ROM_GPIOPinWrite(DRV_ENABLE_RIGHT_CHN_PORT, DRV_ENABLE_RIGHT_CHN_PIN, 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 LED_Display_init(void) { ROM_SysCtlPeripheralEnable(LED1_PERIPHERAL); ROM_SysCtlPeripheralEnable(LED2_PERIPHERAL); ROM_SysCtlPeripheralEnable(LED3_PERIPHERAL); ROM_GPIOPinTypeGPIOOutput(LED1_PORT, LED1_PIN); ROM_GPIOPinTypeGPIOOutput(LED2_PORT, LED2_PIN); ROM_GPIOPinTypeGPIOOutput(LED3_PORT, LED3_PIN); LED1_OFF(); LED2_OFF(); LED3_OFF(); }
void InitialiseDisplayTFT(void) { /* Enable peripherals */ ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlDelay(100); /* Set command and reset pin as outputs */ ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, TFT_RESET_PIN | TFT_COMMAND_PIN); /* Enable CS pin as output */ ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5); /* Enable pin PB7 for SSI2 SSI2TX */ ROM_GPIOPinConfigure(GPIO_PB7_SSI2TX); ROM_GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_7); /* Enable pin PB6 for SSI2 SSI2RX */ ROM_GPIOPinConfigure(GPIO_PB6_SSI2RX); ROM_GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_6); /* Enable pin PB4 for SSI2 SSI2CLK */ ROM_GPIOPinConfigure(GPIO_PB4_SSI2CLK); ROM_GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4); /* Configure the SSI2 port to run at 15.0MHz */ ROM_SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 15000000, 8); ROM_SSIEnable(SSI2_BASE); /* Reset the display */ TFT_RESET_HIGH; my_delay_tft(100); TFT_RESET_LOW; my_delay_tft(100); TFT_RESET_HIGH; my_delay_tft(100); /* Send command sequence */ init_sequence_tft(); cursor_y = cursor_x = 0; textcolor = 0xFFFF; textbgcolor = 0x0000; wrap = 1; }
//***************************************************************************** // // Initialize the IO used in this demo // //***************************************************************************** void io_init(void) { // // Configure Port F0 for as an output for the status LED. // ROM_GPIOPinTypeGPIOOutput(LED_PORT_BASE, LED_PIN); // // Initialize LED to OFF (0) // ROM_GPIOPinWrite(LED_PORT_BASE, LED_PIN, 0); // // Enable the peripherals used by this example. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); // // Configure the timer used to pace the animation. // ROM_TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC); // // Setup the interrupts for the timer timeouts. // ROM_IntEnable(INT_TIMER2A); ROM_TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT); // // Set the timer for the current animation speed. This enables the // timer as a side effect. // io_set_timer(g_ulAnimSpeed); }
void TwoWire::forceStop(void) { //force a stop to release the bus ROM_GPIOPinTypeGPIOOutput(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule] | g_uli2cSDAPins[i2cModule]); ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule], 0); ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule], g_uli2cSCLPins[i2cModule]); ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule], g_uli2cSDAPins[i2cModule]); ROM_GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]); ROM_GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]); //reset I2C controller //without resetting the I2C controller, the I2C module will //bring the bus back to it's erroneous state ROM_SysCtlPeripheralReset(g_uli2cPeriph[i2cModule]); while(!ROM_SysCtlPeripheralReady(g_uli2cPeriph[i2cModule])); ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, speedMode);//Bus speed if(speedMode==I2C_SPEED_FASTMODE_PLUS)//Force 1Mhz { uint32_t ui32TPR = ((F_CPU + (2 * 10 * 1000000l) - 1) / (2 * 10 * 1000000l)) - 1; HWREG(MASTER_BASE + I2C_O_MTPR) = ui32TPR; } }
void Init_LED() { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4); //配置PF4为数值输出 ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4); //PF4,输出高电平 }
void init() { ROM_FPUEnable(); ROM_FPULazyStackingEnable(); ROM_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIO_PORTB_DIR_R = 0x00; GPIO_PORTB_DEN_R = 0xff; ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_GPIOPinConfigure(GPIO_PA0_U0RX); ROM_GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioInit(0); ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 1000000); ROM_SysTickEnable(); ROM_SysTickIntEnable(); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); reset(); }
/** * Initalize the RS232 port. * */ void uart0_init(unsigned long ubr) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Enable the GPIO port that is used for the on-board LED. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Enable the GPIO pins for the LED (PF2). // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); ROM_IntMasterEnable(); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); ROM_IntEnable(INT_UART0); ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); }
void MCInitGpio() { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // PIN1, PIN2 - In1B,In2B (MotorB) ; PIN4,PIN5 - In1A,In2A ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_4|GPIO_PIN_5); }
void lcd_init() { ROM_SysCtlPeripheralEnable(LCD_PORTENABLE); ROM_GPIOPinTypeGPIOOutput(LCD_PORT, (LCD_RS | LCD_E | LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7)); // Please refer to the HLCD_D44780 datasheet for how these initializations work! ROM_SysCtlDelay(ROM_SysCtlClockGet()/3/2); ROM_GPIOPinWrite(LCD_PORT, LCD_RS, 0x00); ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, 0x30); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00); ROM_SysCtlDelay((50e-3)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, 0x30); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3);ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00); ROM_SysCtlDelay((50e-3)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, 0x30); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00); ROM_SysCtlDelay((10e-3)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, 0x20); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x02);ROM_SysCtlDelay((20e-6)*ROM_SysCtlClockGet()/3); ROM_GPIOPinWrite(LCD_PORT, LCD_E, 0x00); ROM_SysCtlDelay((10e-3)*ROM_SysCtlClockGet()/3); lcd_command(LCD_CLEARDISPLAY); // Clear the screen. lcd_command(0x06); // Cursor moves right. lcd_command(LCD_DISPLAYCONTROL | LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF); // Don't show any cursor, turn on LCD. }
int main(void) { // // Device configuration: PLL is used, crystal of 16 MHz, main clock is the source clock // System clock divider = 4 // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // PF2 as output (blue led) // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN); ButtonsInit(); // Init buttons // Loop while(1) { In = ROM_GPIOPinRead(BUTTONS_GPIO_BASE, RIGHT_BUTTON); // Read PORTF 0 if (In==0){ ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, LED_BLUE); // Turn on LED BLUE ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, 0); } else { ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED, LED_RED); // Turn on LED RED ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, 0); } } }
static void sys_setup(void) { ROM_FPULazyStackingEnable(); ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); }
int main() { ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN); HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK)=GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE + GPIO_O_CR)|=GPIO_PIN_0; ROM_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, SW2|SW1); ROM_GPIOPadConfigSet(GPIO_PORTF_BASE,SW2|SW1,GPIO_STRENGTH_4MA,GPIO_PIN_TYPE_STD_WPU); Out=0x02; while (1) { // set the red LED pin high, others low In1 = ROM_GPIOPinRead(GPIO_PORTF_BASE,SW1|SW2); In2 = (In1 & 0x10) >>4; In1 = In1 & 0x01; if(In1 == 0 && In2 == 1 && flag == 0) { flag =1; Out = Out << 1; if (Out > 0x08) Out = 0x02; } else if (In1 == 1 && In2 == 0 && flag == 0) { flag =1; Out = Out >> 1; if (Out<0x02) Out=0x08; } else if (In1 ==1 && In2==1 && flag ==1)
void pinMode(uint8_t pin, uint8_t mode) { uint8_t bit = digitalPinToBitMask(pin); uint8_t port = digitalPinToPort(pin); uint32_t portBase = (uint32_t) portBASERegister(port); volatile uint32_t *lock = portLOCKRegister(port); volatile uint32_t *cr = portCRRegister(port); if (port == NOT_A_PORT) return; if (mode == INPUT) { ROM_GPIOPinTypeGPIOInput(portBase, bit); } else if (mode == INPUT_PULLUP) { *lock = GPIO_LOCK_KEY_DD; *cr |= bit; *lock = 0; ROM_GPIODirModeSet(portBase, bit, GPIO_DIR_MODE_IN); GPIOPadConfigSet(portBase, bit, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); *cr &= ~bit; } else if (mode == INPUT_PULLDOWN) { *lock = GPIO_LOCK_KEY_DD; *cr |= bit; *lock = 0; ROM_GPIODirModeSet(portBase, bit, GPIO_DIR_MODE_IN); GPIOPadConfigSet(portBase, bit, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD); *cr &= ~bit; } else {//mode == OUTPUT ROM_GPIOPinTypeGPIOOutput(portBase, bit); } }
static void led_setup(void) { #define LED_RED GPIO_PIN_1 #define LED_BLUE GPIO_PIN_2 #define LED_GREEN GPIO_PIN_3 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED | LED_BLUE | LED_GREEN); }
/** * @brief initialize the boards on-boards LEDS. */ static void leds_init(void) { /* enable clock for PORTF */ ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); /*configure the pins as general output */ ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); }
int main() { ROM_SysCtlPeripheralEnable(SPI_LED_SYSCTL); ROM_GPIOPinTypeGPIOOutput(SPI_LED_BASE, SPI_LED_ERROR|SPI_LED_BUSY); clockFreq = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); ROM_SysCtlPeripheralEnable(COCO_CS_SYSCTL); ROM_GPIOPinTypeGPIOOutput(COCO_CS_BASE, COCO_CS); ROM_GPIOPinWrite(COCO_CS_BASE, COCO_CS, COCO_CS); uart_init(clockFreq); disk_initialize(0); ROM_GPIOPinWrite(SPI_LED_BASE, SPI_LED_ERROR|SPI_LED_BUSY, SPI_LED_BUSY); if ((res = f_mount(0, &fatfs_obj))) { ROM_GPIOPinWrite(SPI_LED_BASE, SPI_LED_ERROR|SPI_LED_BUSY, SPI_LED_ERROR); UART_printstr("Mount failed!\r\n"); while (1); } setAddr(0x413000); for (int i=0; i < 4*128; i++) setData(f88[i]); setAddr(0x420000); if ((res = f_open(&fil_obj, "/dod.rom", FA_READ)) != FR_OK) { ROM_GPIOPinWrite(SPI_LED_BASE, SPI_LED_ERROR|SPI_LED_BUSY, SPI_LED_ERROR); UART_printstr("Can't open test file.\r\n"); while (1); } programRom(&fil_obj); f_close(&fil_obj); ROM_GPIOPinWrite(SPI_LED_BASE, SPI_LED_ERROR|SPI_LED_BUSY, 0); while (1); }
//***************************************************************************** // // Print "Hello World!" to the UART on the Intelligent UART Module. // //***************************************************************************** int main(void) { // // Run from the PLL at 120 MHz. // g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Configure the device pins. // PinoutSet(false, false); // // Enable the GPIO pins for the LED D1 (PN1). // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_1); // // Initialize the UART. // ConfigureUART(); // // Hello! // UARTprintf("Hello, world!\n"); // // We are finished. Hang around flashing D1. // while(1) { // // Turn on D1. // LEDWrite(CLP_D1, 1); // // Delay for a bit. // SysCtlDelay(g_ui32SysClock / 10 / 3); // // Turn off D1. // LEDWrite(CLP_D1, 0); // // Delay for a bit. // SysCtlDelay(g_ui32SysClock / 10 / 3); } }
void pin_init(void) { // Enable all the GPIO peripherals ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS); // PF1/PK4/PK6 are used for Ethernet LEDs ROM_GPIOPinConfigure(GPIO_PK4_EN0LED0); ROM_GPIOPinConfigure(GPIO_PK6_EN0LED1); GPIOPinTypeEthernetLED(GPIO_PORTK_BASE, GPIO_PIN_4); GPIOPinTypeEthernetLED(GPIO_PORTK_BASE, GPIO_PIN_6); #ifdef DEVKIT // PN5 is used for the user LED ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_5); ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_5, 0); #else // PA0-1 is used for the user LED ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_1 | GPIO_PIN_0); ROM_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_1 | GPIO_PIN_0, GPIO_PIN_0); // PH2-3 is used for the user LED ROM_GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_2); ROM_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_3 | GPIO_PIN_2, GPIO_PIN_3 | GPIO_PIN_2); #endif }
void setup() { //--------------------- GENERAL --------------------- // 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_FPUEnable(); 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); ROM_IntMasterEnable(); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_6); //--------------------- UART --------------------- ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // Configure the UART for 115,200, 8-N-1 operation. ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Enable the UART interrupt. ROM_IntEnable(INT_UART0); ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //--------------------- SSI --------------------- SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); GPIOPinConfigure(GPIO_PA2_SSI0CLK); GPIOPinConfigure(GPIO_PA3_SSI0FSS); GPIOPinConfigure(GPIO_PA4_SSI0RX); GPIOPinConfigure(GPIO_PA5_SSI0TX); GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5 | GPIO_PIN_4 | GPIO_PIN_3 | GPIO_PIN_2); SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 8); SSIEnable(SSI0_BASE); }
//Initialize as a master void TwoWire::begin(void) { if(i2cModule == NOT_ACTIVE) { i2cModule = BOOST_PACK_WIRE; } ROM_SysCtlPeripheralEnable(g_uli2cPeriph[i2cModule]); //Configure GPIO pins for I2C operation ROM_GPIOPinConfigure(g_uli2cConfig[i2cModule][0]); ROM_GPIOPinConfigure(g_uli2cConfig[i2cModule][1]); ROM_GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]); ROM_GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]); ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, speedMode);//Bus speed if(speedMode==I2C_SPEED_FASTMODE_PLUS)//Force 1Mhz { uint32_t ui32TPR = ((F_CPU + (2 * 10 * 1000000l) - 1) / (2 * 10 * 1000000l)) - 1; HWREG(MASTER_BASE + I2C_O_MTPR) = ui32TPR; } //force a stop condition if(!ROM_GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule])) forceStop(); //Handle any startup issues by pulsing SCL if(ROM_I2CMasterBusBusy(MASTER_BASE) || ROM_I2CMasterErr(MASTER_BASE) || !ROM_GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule])) { uint8_t doI = 0; ROM_GPIOPinTypeGPIOOutput(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]); unsigned long mask = 0; do { for(unsigned long i = 0; i < 10 ; i++) { if(speedMode==I2C_SPEED_FASTMODE_PLUS) ROM_SysCtlDelay(F_CPU/1000000/3);//1000Hz=desired frequency, delay iteration=3 cycles else if(speedMode==I2C_SPEED_FASTMODE) ROM_SysCtlDelay(F_CPU/400000/3);//400Hz=desired frequency, delay iteration=3 cycles else ROM_SysCtlDelay(F_CPU/100000/3);//100Hz=desired frequency, delay iteration=3 cycles mask = (i%2) ? g_uli2cSCLPins[i2cModule] : 0; ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule], mask); } doI++; } while(ROM_I2CMasterBusBusy(MASTER_BASE) && doI < 100); ROM_GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]); if(!ROM_GPIOPinRead(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule])) forceStop(); } }
void init_am27c_ports(void) { unsigned char i; for(i = 0; i < NELEMS(PERIPH); i++) ROM_SysCtlPeripheralEnable(PERIPH[i]); for(i = 0; i < NELEMS(A_PORTS); i++) ROM_GPIOPinTypeGPIOOutput(A_PORTS[i], A_PINS[i]); HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD; HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01; HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0; for(i = 0; i < NELEMS(DQ_PORTS); i++) { ROM_GPIOPinTypeGPIOInput(DQ_PORTS[i], DQ_PINS[i]); ROM_GPIOPadConfigSet(DQ_PORTS[i], DQ_PINS[i], GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); } for(i = 0; i < NELEMS(CTL_PORTS); i++) ROM_GPIOPinTypeGPIOOutput(CTL_PORTS[i], CTL_PINS[i]); }
int main() { uint8_t ui8Buttons; uint8_t ui8ButtonsChanged; ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,LED_RED | LED_BLUE | LED_GREEN); ROM_SysCtlPeripheralEnable(BUTTONS_GPIO_PERIPH); HWREG(BUTTONS_GPIO_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(BUTTONS_GPIO_BASE + GPIO_O_CR) |= 0x01; HWREG(BUTTONS_GPIO_BASE + GPIO_O_LOCK) = 0; ROM_GPIODirModeSet(BUTTONS_GPIO_BASE, ALL_BUTTONS, GPIO_DIR_MODE_IN); ROM_GPIOPadConfigSet(BUTTONS_GPIO_BASE,ALL_BUTTONS, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); g_ui8ButtonStates = ROM_GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS); for(;;) { /* ui8Buttons = ButtonsPoll(&ui8ButtonsChanged, 0); if(BUTTON_PRESSED(LEFT_BUTTON, ui8Buttons, ui8ButtonsChanged)) { ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_RED); }//Button leftside, if button leftside is pressed the LED will be flash red else if(BUTTON_PRESSED(RIGHT_BUTTON, ui8Buttons, ui8ButtonsChanged)) { ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_GREEN); }//Button rightside, if button leftside is pressed the LED will be flash green else if(BUTTON_RELEASED(LEFT_BUTTON|RIGHT_BUTTON, ui8Buttons, ui8ButtonsChanged)) { ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, 0); }//If the buttons will be release the LED turn off. */ //----Wenn beide Buttons gedrueckt werden leuchten auch --- ui8Buttons = (uint8_t)~ROM_GPIOPinRead(BUTTONS_GPIO_BASE, ALL_BUTTONS); led_switch = 0; if(LEFT_BUTTON & ui8Buttons) led_switch |= LED_RED; if(RIGHT_BUTTON & ui8Buttons) led_switch |= LED_GREEN; ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, led_switch); } return 0; }
int main(void) { volatile int32_t i2 = i; volatile int32_t j2 = j; volatile float a = 3.14; while (1) { ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0xFF); } return 0; }
/* * Set up the Optode (give it power and set up UART3). * DO THIS BEFORE POLLING. */ void openOptode(void) { //set up the Optode's GPIO enable pin (pin 81) ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0); //turn on power OPTODE_ON; //UART3 runs to the Optode, set it up: UART3Init(); }
int main() { ROM_SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, LED_RED|LED_BLUE|LED_GREEN); for (;;) { // set the red LED pin high, others low ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, LED_RED); ROM_SysCtlDelay(4000000); ROM_GPIOPinWrite(GPIO_PORTF_BASE, LED_RED|LED_GREEN|LED_BLUE, 0); ROM_SysCtlDelay(5000000); } }