void PSO_Timers() { uint32_t ui32Period; SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); ui32Period = (SysCtlClockGet() / 10) / 2; TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period -1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); TimerEnable(TIMER0_BASE, TIMER_A); // ROM_TimerControlEvent(WTIMER1_BASE, TIMER_BOTH,TIMER_EVENT_BOTH_EDGES); // ROM_TimerControlEvent(WTIMER5_BASE, TIMER_BOTH,TIMER_EVENT_BOTH_EDGES); // // ROM_TimerConfigure(WTIMER1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_TIME|TIMER_CFG_B_CAP_TIME); // Timer 1-A and -B events edge-timer // ROM_TimerConfigure(WTIMER5_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_TIME|TIMER_CFG_B_CAP_TIME); // Timer 1-A and -B events edge-timer // // // ROM_GPIOPinTypeTimer(GPIO_PORTC_BASE,GPIO_PIN_6); // Set Port PC6 as Capture // ROM_GPIOPinConfigure(GPIO_PC6_WT1CCP0); // // ROM_GPIOPinTypeTimer(GPIO_PORTC_BASE,GPIO_PIN_7); // Set Port PC7 as Capture // ROM_GPIOPinConfigure(GPIO_PC7_WT1CCP1); // // ROM_GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_6); // Set Port PD6 as Capture // ROM_GPIOPinConfigure(GPIO_PD6_WT5CCP0); // // ROM_GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_7); // Set Port PD7 as Capture // ROM_GPIOPinConfigure(GPIO_PD7_WT5CCP1); // // TimerSynchronize(TIMER0_BASE, WTIMER_1A_SYNC|WTIMER_1B_SYNC|WTIMER_5A_SYNC|WTIMER_5B_SYNC); // // // Timer Interrupt Configuration // ROM_IntEnable(INT_WTIMER1A); // Enable Wide Timer 1-A Interrupt (Macro shall be used individually) // ROM_IntEnable(INT_WTIMER1B); // Enable Wide Timer 1-B Interrupt (Macro shall be used individually) // ROM_IntEnable(INT_WTIMER5A); // Enable Wide Timer 5-A Interrupt (Macro shall be used individually) // ROM_IntEnable(INT_WTIMER5B); // Enable Wide Timer 5-B Interrupt (Macro shall be used individually) // ROM_TimerIntEnable(WTIMER1_BASE, TIMER_CAPA_EVENT|TIMER_CAPB_EVENT); // ROM_TimerIntEnable(WTIMER5_BASE, TIMER_CAPA_EVENT|TIMER_CAPB_EVENT); // ROM_TimerEnable(WTIMER1_BASE, TIMER_BOTH); // ROM_TimerEnable(WTIMER5_BASE, TIMER_BOTH); // ROM_IntMasterEnable(); }
/** * 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; /* set MAC hardware address */ EthernetMACAddrSet(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); }
void turret_init(void) { pwm_init(); adc_init(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER4); TimerConfigure(TIMER4_BASE, TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC | TIMER_CFG_SPLIT_PAIR); //Timer B pour les actionneurs TimerLoadSet(TIMER4_BASE, TIMER_A, SysCtlClockGet()/50); IntEnable(INT_TIMER4A); TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT); TimerEnable(TIMER4_BASE, TIMER_A); TimerEnable(TIMER4_BASE, TIMER_B); }
void UART_init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTFIFOEnable(UART0_BASE); UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX4_8); UARTIntClear(UART0_BASE, 0xFFFFFFFF); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX); uart_transmit("AmpTraXX2!\n", 11); }
//***************************************************************************** // //! Registers an interrupt handler for the watchdog timer interrupt. //! //! \param ui32Base is the base address of the watchdog timer module. //! \param pfnHandler is a pointer to the function to be called when the //! watchdog timer interrupt occurs. //! //! This function does the actual registering of the interrupt handler. This //! function also enables the global interrupt in the interrupt controller; the //! watchdog timer interrupt must be enabled via WatchdogEnable(). It is the //! interrupt handler's responsibility to clear the interrupt source via //! WatchdogIntClear(). //! //! \sa IntRegister() for important information about registering interrupt //! handlers. //! //! \note For parts with a watchdog timer module that has the ability to //! generate an NMI instead of a standard interrupt, this function registers //! the standard watchdog interrupt handler. To register the NMI watchdog //! handler, use IntRegister() to register the handler for the //! \b FAULT_NMI interrupt. //! //! \return None. // //***************************************************************************** void WatchdogIntRegister(uint32_t ui32Base, void (*pfnHandler)(void)) { // // Check the arguments. // ASSERT((ui32Base == WATCHDOG0_BASE) || (ui32Base == WATCHDOG1_BASE)); // // Register the interrupt handler. // IntRegister(INT_WATCHDOG_TM4C123, pfnHandler); // // Enable the watchdog timer interrupt. // IntEnable(INT_WATCHDOG_TM4C123); }
void configure_uart_printf(void) { g_ulBase = UART3_BASE; SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3); GPIOPinConfigure(GPIO_PC6_U3RX); GPIOPinConfigure(GPIO_PC7_U3TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7); UARTConfigSetExpClk(UART3_BASE, SysCtlClockGet(), 38400, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); IntEnable(INT_UART3); UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_TX); }
void UART0_init(void) { 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); UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); UARTStdioConfig(0, 115200, 16000000); IntMasterEnable(); //全局中断使能 IntEnable(INT_UART0); //使能串口0中断 UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); //使能串口0接收中断和接收超时中断 UARTEnable(UART0_BASE); //使能串口1(UARTO)发送和接收 }
static void ConfigureIntUART(void) { #ifdef _TMS320C6X IntRegister(C674X_MASK_INT4, UARTIsr); IntEventMap(C674X_MASK_INT4, SYS_INT_UART2_INT); IntEnable(C674X_MASK_INT4); #else /* Registers the UARTIsr in the Interrupt Vector Table of AINTC. */ IntRegister(SYS_INT_UARTINT2, UARTIsr); /* Map the channel number 2 of AINTC to UART2 system interrupt. */ IntChannelSet(SYS_INT_UARTINT2, 2); IntSystemEnable(SYS_INT_UARTINT2); #endif }
void delay_msec(unsigned int delay_time) { TimerInterrupt = 0; TimerLoadSet(GPTIMER3_BASE, GPTIMER_A, ((32000/20) * delay_time)); IntMasterEnable(); TimerIntEnable(GPTIMER3_BASE, GPTIMER_TIMA_TIMEOUT); IntEnable(INT_TIMER3A); TimerEnable(GPTIMER3_BASE, GPTIMER_A); while(TimerInterrupt != TIME_REACHED); TimerInterrupt = 0; }
void InitTimer2(uint32_t ui32SysClock) { // Enable the peripherals. SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); // Configure the 32-bit periodic timer. TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER2_BASE, TIMER_A, ui32SysClock / F_INTERRUPTS); // Setup the interrupts for the timer timeouts. IntEnable(INT_TIMER2A); TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT); // Enable the timer. TimerEnable(TIMER2_BASE, TIMER_A); }
/* * function: InitSamplingTimer * return: none * */ void InitSamplingTimer() { SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerControlTrigger(TIMER0_BASE, TIMER_A, true); TimerLoadSet(TIMER0_BASE, TIMER_A, LoadTimer); /* * timer set : 20 (us) * */ // Enable the sampling interrupt IntEnable(INT_TIMER0A); // When timer hits zero, call interrupt TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); // Start the sampling timer TimerEnable(TIMER0_BASE, TIMER_A); }
void InitUart2(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA6_U2RX); GPIOPinConfigure(GPIO_PA7_U2TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_6 | GPIO_PIN_7); UARTFIFOLevelSet(UART2_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTTxIntModeSet(UART2_BASE, UART_TXINT_MODE_EOT); UARTFIFOEnable(UART2_BASE); IntEnable(INT_UART2); UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); }
void InitUart4(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA2_U4RX); GPIOPinConfigure(GPIO_PA3_U4TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3); UARTFIFOLevelSet(UART4_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTTxIntModeSet(UART4_BASE, UART_TXINT_MODE_EOT); UARTFIFOEnable(UART4_BASE); IntEnable(INT_UART4); UARTIntEnable(UART4_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); }
void InitUart0(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); UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_EOT); UARTFIFOEnable(UART0_BASE); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); }
//***************************************************************************** // //! Initialization the I2C bus module. //! //! \param bus specifies the i2c bus data structure. //! //! This function initialization the I2C hardware bus, it will open the i2c peripheral //! and config the I2C gpio //! //! \return 0 is OK. // //***************************************************************************** int ipmi_i2c_bus_init(ipmi_i2c_bus *bus) { // // Check the arguments. // ASSERT(bus->sys_peripheral); ASSERT(bus->i2c_scl_periph); ASSERT(bus->i2c_sda_periph); ASSERT(bus->i2c_scl_gpio_port); ASSERT(bus->i2c_sda_gpio_port); ASSERT(bus->i2c_scl_gpio_pin); ASSERT(bus->i2c_sda_gpio_pin); ASSERT(bus->i2c_hw_master_base); // 初始化链表结构 INIT_LIST_HEAD(&bus->list); // 初始化系统硬件外设 SysCtlPeripheralEnable(bus->sys_peripheral); // 初始化SCL管脚硬件外设 SysCtlPeripheralEnable(bus->i2c_scl_periph); if (bus->i2c_scl_gpio_mux) GPIOPinConfigure(bus->i2c_scl_gpio_mux); GPIOPinTypeI2C(bus->i2c_scl_gpio_port, bus->i2c_scl_gpio_pin); // 初始化SDA管脚硬件外设 SysCtlPeripheralEnable(bus->i2c_sda_periph); if (bus->i2c_sda_gpio_mux) GPIOPinConfigure(bus->i2c_sda_gpio_mux); GPIOPinTypeI2C(bus->i2c_sda_gpio_port, bus->i2c_sda_gpio_pin); // 设备使能,开中断 I2CMasterInit(bus->i2c_hw_master_base, false); if (bus->i2c_int) { //I2CIntRegister(bus->i2c_hw_master_base); IntEnable(bus->i2c_int); I2CMasterIntEnable(bus->i2c_hw_master_base); } I2CMasterEnable(bus->i2c_hw_master_base); list_add(&bus->list, &ipmi_i2c_bus_root.head); ipmi_i2c_bus_root.count++; return 0; }
void initQEI(void){ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); //PhA sur C4 et PhB sur C6 SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //PhA sur E3 et PhB sur E2 SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI1); //init QEI0 du micro pour moteur 0 GPIOPinConfigure(GPIO_PC4_PHA0); GPIOPinConfigure(GPIO_PC6_PHB0); GPIOPinTypeQEI(GPIO_PORTC_BASE, GPIO_PIN_4); //Ph A GPIOPinTypeQEI(GPIO_PORTC_BASE, GPIO_PIN_6); //Ph B QEIDisable(QEI0_BASE); QEIConfigure(QEI0_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET| QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1000000); //64 counts par révolution de moteur avec un ratio 100:1 QEIEnable(QEI0_BASE); QEIPositionSet(QEI0_BASE,0); QEIVelocityDisable(QEI0_BASE); QEIVelocityConfigure (QEI0_BASE, QEI_VELDIV_1, ROM_SysCtlClockGet()*dt); QEIVelocityEnable(QEI0_BASE); //init QEI1 du micro pour moteur 1 GPIOPinConfigure(GPIO_PE3_PHA1); GPIOPinConfigure(GPIO_PE2_PHB1); GPIOPinTypeQEI(GPIO_PORTE_BASE, GPIO_PIN_3); //Ph A GPIOPinTypeQEI(GPIO_PORTE_BASE, GPIO_PIN_2); //Ph B QEIDisable(QEI1_BASE); QEIConfigure(QEI1_BASE, (QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_NO_RESET| QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 1000000); //64 counts par révolution de moteur avec un ratio 100:1 QEIEnable(QEI1_BASE); QEIPositionSet(QEI1_BASE,0); QEIVelocityDisable(QEI1_BASE); QEIVelocityConfigure (QEI1_BASE, QEI_VELDIV_1, ROM_SysCtlClockGet()*dt); QEIVelocityEnable(QEI1_BASE); //init decodeur fait a la mitaine pour moteur 2 et 3 (pins J4 et J5 pour moteur 2, J6 et J7 pour moteur 3) GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD); GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7); GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7, GPIO_BOTH_EDGES); GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 | GPIO_PIN_7); IntEnable(INT_GPIOE); position_m0 = 0; position_m1 = 0; position_m2 = 0; position_m3 = 0; }
//============================================================================// //== ADC初始化函数 ==// //============================================================================// //==说明: 对于测试将方波滤波成为正弦波的测试,需要改变AD的采样频率 ==// //== SYSCTL_ADCSPEED_1MSPS // 采样速率:1M次采样/秒 ==// //== SYSCTL_ADCSPEED_500KSPS // 采样速率:500K次采样/秒 ==// //== SYSCTL_ADCSPEED_250KSPS // 采样速率:250K次采样/秒 ==// //== SYSCTL_ADCSPEED_125KSPS // 采样速率:125K次采样/秒 ==// //== 频率高的方波AD采样频率应适当增加 ==// //==入口参数: 无 ==// //==出口参数: 无 ==// //==返回值: 无 ==// //============================================================================// void ADCInit(void) { SysCtlPeriEnable(SYSCTL_PERIPH_ADC); // 使能ADC模块 SysCtlADCSpeedSet(SYSCTL_ADCSPEED_500KSPS); // 设置ADC采样速率 ADCSequDisable(ADC_BASE, 0); // 配置前先禁止采样序列 // 采样序列配置:ADC基址,采样序列编号,触发事件,采样优先级 ADCSequConfig(ADC_BASE, 0, ADC_TRIGGER_PROCESSOR, 0); // 采样步进设置:ADC基址,采样序列编号,步值,通道设置(ADC0转换完后停止触发中断) ADCSequStepConfig(ADC_BASE, 0, 0, ADC_CTL_CH0 | ADC_CTL_END | ADC_CTL_IE); ADCIntEnable(ADC_BASE, 0); // 使能ADC中断 IntEnable(INT_ADC0); // 使能ADC采样序列中断 ADCIntRegister(ADC_BASE, 0, ADC_ISR); IntMasterEnable( ); // 使能处理器中断 ADCSequEnable(ADC_BASE, 0); // 使能采样序列 }
/* * Function Name: setTimer() * Input: none * Output: none * Description: Enable the timer * Example Call: setTimer(); */ void setTimer(void) { uint32_t ui32Period; SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); // Enables the timer that operates for 1000ms ui32Period = (SysCtlClockGet()); TimerLoadSet(TIMER0_BASE, TIMER_A, ui32Period - 1); // Enable the interrupt IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); IntMasterEnable(); // Enable the timer TimerEnable(TIMER0_BASE, TIMER_A); }
/** * @brief Función para inicializar uno de los puertos UART. * * @return - * * Inicializa el puerto 0 de la UART. */ int UART_open(int nPort) { initUartPins(nPort); UARTDisable(gs_ul_uarts_bases[nPort]); UARTConfigSetExpClk(gs_ul_uarts_bases[nPort], SysCtlClockGet(), BAUD_RATE, DATA_FRAME); UARTEnable(gs_ul_uarts_bases[nPort]); gs_cu_uarts[nPort].inHead = 0; gs_cu_uarts[nPort].inTail = 0; gs_cu_uarts[nPort].inHead = 0; gs_cu_uarts[nPort].inTail = 0; gs_cu_uarts[nPort].intWhileWriting = 0; gs_cu_uarts[nPort].writingToBuf=0; UARTFIFOLevelSet(gs_ul_uarts_bases[nPort], UART_FIFO_TX1_8, UART_FIFO_RX1_8); IntEnable(gs_ul_uarts_ints[nPort]); UARTIntEnable(gs_ul_uarts_bases[nPort], UART_INT_TX | UART_INT_RX | UART_INT_RT); return 0; }
void qeiInit(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01; HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0; GPIOPinTypeQEI(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinTypeQEI(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinConfigure(GPIO_PF0_PHA0); GPIOPinConfigure(GPIO_PF1_PHB0); QEIConfigure(QEI0_BASE,QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_RESET | QEI_CONFIG_NO_SWAP,3999); QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, SysCtlClockGet()/QEIfrequency); QEIVelocityEnable(QEI0_BASE); QEIIntEnable(QEI0_BASE, QEI_INTTIMER); IntEnable(INT_QEI0); QEIEnable(QEI0_BASE); }
int ADC_Collect(unsigned int channelNum, unsigned int fs, void (*task)(unsigned short)){ unsigned long config; ADCTask = task; // Determine input channel switch(channelNum){ case 0: config = ADC_CTL_CH0; break; case 1: config = ADC_CTL_CH1; break; case 2: config = ADC_CTL_CH2; break; case 3: config = ADC_CTL_CH3; break; } ADCSequenceDisable(ADC0_BASE, 0); // Enable the ADC0 for interrupt Sequence 0 with lower priority then single shot ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_TIMER, 1); // Configuring steps of sequence, last step contains ADC_CTL_END and ADC_CTL_IE config paramter config |= ADC_CTL_END | ADC_CTL_IE; ADCSequenceStepConfigure(ADC0_BASE, 0, 0, config); // Disabling Timer0A for configuration TimerDisable(TIMER0_BASE, TIMER_A); // Configure as 16 bit timer and trigger ADC conversion TimerControlTrigger(TIMER0_BASE, TIMER_A, true); TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/ fs); TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ADCSequenceOverflowClear(ADC0_BASE, 0); ADCSequenceUnderflowClear(ADC0_BASE, 0); ADCIntClear(ADC0_BASE, 0); ADCSequenceEnable(ADC0_BASE, 0); TimerEnable(TIMER0_BASE, TIMER_A); TimerIntEnable(TIMER0_BASE, TIMER_A); ADCIntEnable(ADC0_BASE, 0); IntEnable(INT_ADC0SS0); return 1; }
void Tach_Init(void) { SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_0); /* Setup Timer0A Counter in edge-time-capture mode. */ TimerDisable(TIMER0_BASE, TIMER_A); //TimerConfigure(TIMER0_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_CAP_TIME | TIMER_CFG_B_PERIODIC); TimerIntEnable(TIMER0_BASE, TIMER_CAPA_EVENT | TIMER_TIMA_TIMEOUT); TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_POS_EDGE); TimerLoadSet(TIMER0_BASE, TIMER_A, 0xFFFF); IntEnable(INT_TIMER0A); // Activate timer TimerEnable(TIMER0_BASE, TIMER_A); }
//***************************************************************************** // //! This enables the PPS Port K GPIO interrupt then waits for a PPS interrupt //! and subsequent data log. // //***************************************************************************** int ppsDataLog(void) { // // Enable interrupt to fire GPS read/write on next PPS signal. // IntEnable(INT_GPIOK); // // Spin here waiting for a PPS signal // while (!logComplete); // // Reset the log indicator // logComplete = 0; return 0; }
//***************************************************************************** //! Registers an interrupt handler for the I2C module. //! //! \param ulBase is the base address of the I2C Master module. //! \param pfnHandler is a pointer to the function to be called when the //! I2C interrupt occurs. //! //! This sets the handler to be called when an I2C interrupt occurs. This will //! enable the global interrupt in the interrupt controller; specific I2C //! interrupts must be enabled via I2CMasterIntEnable() and //! I2CSlaveIntEnable(). If necessary, it is the interrupt handler's //! responsibility to clear the interrupt source via I2CMasterIntClear() and //! I2CSlaveIntClear(). //! //! \sa IntRegister() for important information about registering interrupt //! handlers. //! //! \return None. //***************************************************************************** void I2CIntRegister(unsigned long ulBase, void (*pfnHandler)(void)) { unsigned long ulInt; // Check the arguments. ASSERT((ulBase == I2C0_MASTER_BASE) || (ulBase == I2C1_MASTER_BASE)); // Determine the interrupt number based on the I2C port. ulInt = (ulBase == I2C0_MASTER_BASE) ? INT_I2C0 : INT_I2C1; // Register the interrupt handler, returning an error if an error occurs. IntRegister(ulInt, pfnHandler); // Enable the I2C interrupt. IntEnable(ulInt); }
/* Set up I2C pins and clock slow/fast rate400 true = 400KHz, false 100KHz */ void MasterI2C0Init(int rate400) { //I2CMasterEnable(I2C0_MASTER_BASE); // causes fault // // Enable the I2C and GPIO port B blocks as they are needed by this driver. // SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //Setup Mux GPIOPinConfigure(GPIO_PB2_I2C0SCL); GPIOPinConfigure(GPIO_PB3_I2C0SDA); GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3); //Set up direction //Reconfigure for correct operation GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_OD); // // Configure the I2C SCL and SDA pins for I2C operation. // //GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); //GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); // // Initialize the I2C master. // I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), true); SysCtlDelay(10000); // delay mandatory here - otherwise portion of SlaveAddrSet() lost! // Register interrupt handler // or we could just edit the startup.c file //I2CIntRegister(I2C0_MASTER_BASE,I2C0IntHandler); // // Enable the I2C interrupt. // IntEnable(INT_I2C0); // already done via I2CIntRegister I2CMasterIntEnableEx(I2C0_MASTER_BASE,I2C_MASTER_INT_DATA | I2C_MASTER_INT_TIMEOUT); // // Enable the I2C master interrupt. // I2CMasterIntEnable(I2C0_MASTER_BASE); }
/** * \brief Init function for the SW2 button. * * Parameters are ignored. They have been included because the prototype is * dictated by the core sensor api. The return value is also not required by * the API but otherwise ignored. * * \param type ignored * \param value ignored * \return ignored */ static int config_sw2(int type, int value) { /* Enable clock to peripheral */ SysCtlPeripheralEnable(BUTTON_SW2_SYSCTL_PORT); /* Configure pin */ config(BUTTON_SW2_PORT, BUTTON_SW2_PIN); /* Enable interrupt in NVIC */ IntEnable(BUTTON_SW2_INT); /* Register callback */ gpio_register_callback(btn_callback, BUTTON_SW2_PORT_NO, BUTTON_SW2_PIN_NO); return 1; }
//******** OS_AddDownTask *************** // add a background task to run whenever the Down arror button is pushed // Inputs: pointer to a void/void background function // priority 0 is highest, 5 is lowest // Outputs: 1 if successful, 0 if this thread can not be added // It is assumed user task will run to completion and return // This task can not spin block loop sleep or kill // It can call issue OS_Signal, it can call OS_AddThread // This task does not have a Thread ID // In lab 2, this function can be ignored // In lab 3, this command will be called will be called 0 or 1 times // In lab 3, there will be up to four background threads, and this priority field // determines the relative priority of these four threads int OS_AddDownTask(void(*task)(void), unsigned long priority) { long status; status = StartCritical(); gButtonThreadDownPt = task; gButtonThreadDownPriority = priority; // Enabling interrupts GPIOPinIntClear(GPIO_PORTE_BASE,GPIO_PIN_1); GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_1); IntPrioritySet(INT_GPIOE, (priority << 5)); IntEnable(INT_GPIOE); EndCritical(status); return 1; }
//***************************************************************************** // // Registers an interrupt handler for the I2C module // //***************************************************************************** void I2CIntRegister(uint32_t ui32Base, void (*pfnHandler)(void)) { uint32_t ui32Int; // Check the arguments. ASSERT(I2CBaseValid(ui32Base)); // Get the interrupt number. ui32Int = INT_I2C_IRQ; // Register the interrupt handler, returning an error if an error occurs. IntRegister(ui32Int, pfnHandler); // Enable the I2C interrupt. IntEnable(ui32Int); }
// ***************************************************************************** void initYaw (void) { // Register the handler for Port F into the vector table GPIOPortIntRegister (GPIO_PORTF_BASE, YawChangeIntHandler); // Enable and configure the port and pin used: input on PF5: Pin 27 & PF7: Pin 29 SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF); GPIOPadConfigSet (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Set up the pin change interrupt (both edges) GPIOIntTypeSet (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7, GPIO_BOTH_EDGES); // Enable the pin change interrupt GPIOPinIntEnable (GPIO_PORTF_BASE, GPIO_PIN_5 | GPIO_PIN_7); IntEnable (INT_GPIOF); // Note: INT_GPIOF defined in inc/hw_ints.h }
void configure_uart_bt(void) { g_ulBase = UART5_BASE; SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5); 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); //UARTFIFODisable(UART5_BASE); UARTIntEnable(UART5_BASE, UART_INT_RX | UART_INT_TX); }