+/rtos
git clone https://git.julia.blue/+/rtos
8216c9a
master
1#include "OS.h" 2#include "timer.h" 3#include "tivaware/gpio.h" 4#include "tivaware/hw_gpio.h" 5#include "tivaware/hw_ints.h" 6#include "tivaware/hw_memmap.h" 7#include "tivaware/hw_types.h" 8#include "tivaware/pin_map.h" 9#include "tivaware/rom.h" 10#include "tivaware/sysctl.h" 11 12void launchpad_init (void ) { 13ROM_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF ); 14HWREG (GPIO_PORTF_BASE + GPIO_O_LOCK )= GPIO_LOCK_KEY ; 15HWREG (GPIO_PORTF_BASE + GPIO_O_CR ) |=1 ; 16ROM_GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE ,0xE ); 17ROM_GPIOPinTypeGPIOInput (GPIO_PORTF_BASE ,0x11 ); 18ROM_GPIOPadConfigSet (GPIO_PORTF_BASE ,0x11 ,GPIO_STRENGTH_2MA , 19GPIO_PIN_TYPE_STD_WPU ); 20} 21 22void enable_button_interupts (uint8_t priority ) { 23ROM_GPIOIntTypeSet (GPIO_PORTF_BASE ,GPIO_PIN_0 |GPIO_PIN_4 , 24GPIO_RISING_EDGE ); 25HWREG (GPIO_PORTF_BASE + GPIO_O_IM )= 0x11 ; 26ROM_IntPrioritySet (INT_GPIOF ,priority <<5 ); 27ROM_IntEnable (INT_GPIOF ); 28} 29 30void led_toggle (uint8_t led ) { 31ROM_GPIOPinWrite (GPIO_PORTF_BASE ,led , 32 ~ROM_GPIOPinRead (GPIO_PORTF_BASE ,led )); 33} 34 35void led_write (uint8_t led ,bool value ) { 36ROM_GPIOPinWrite (GPIO_PORTF_BASE ,led ,value ?led :0 ); 37} 38 39bool left_switch (void ) { 40return !ROM_GPIOPinRead (GPIO_PORTF_BASE ,GPIO_PIN_4 ); 41} 42 43bool right_switch (void ) { 44return !ROM_GPIOPinRead (GPIO_PORTF_BASE ,GPIO_PIN_0 ); 45}