Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- * Toggles led on pin 1 on port N
- *
- * Already set build options (no need to change anything):
- * Stack size set to 1024 byte
- * Heap size disabled - No malloc()
- * No code optimization
- * Strict floating point interrupt behaviour
- * Hardware floating point unit activated
- *
- */
- #include <stdbool.h> /*driverlib header requires stdbool.h to be included a first header file before any driverlib header*/
- #include <stdint.h>
- #include <driverlib/gpio.h>
- #include <driverlib/pin_map.h>/*supplies GPIO_PIN_x*/
- #include <driverlib/sysctl.h>
- #include <inc/hw_memmap.h>/*supplies GPIO_PORTx_BASE*/
- /*Controller is initially clocked with 16MHz*/
- /* !! Changing this define does not change clock speed !! */
- #define F_CPU 16000000
- void main (void) {
- uint32_t ui32Strength;
- uint32_t ui32PinType;
- uint8_t ui8val = 0;
- uint32_t ui32Loop = 0;
- /*activate gpio port n for d1 - d2*/
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
- /* activate gpio port f for d3 - d4 */
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
- /* activate gpio port j for button */
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
- /*configure GPIO_PIN_1 on port N as std pin D1*/
- GPIOPadConfigGet(GPIO_PORTN_BASE, GPIO_PIN_1, &ui32Strength, &ui32PinType);
- GPIOPadConfigSet(GPIO_PORTN_BASE, GPIO_PIN_1,ui32Strength,GPIO_PIN_TYPE_STD);
- /*configure GPIO_PIN_1 on port N as std pin D2*/
- GPIOPadConfigGet(GPIO_PORTN_BASE, GPIO_PIN_0, &ui32Strength, &ui32PinType);
- GPIOPadConfigSet(GPIO_PORTN_BASE, GPIO_PIN_0,ui32Strength,GPIO_PIN_TYPE_STD);
- /*configure GPIO_PIN_1 on port N as std pin D3*/
- GPIOPadConfigGet(GPIO_PORTF_AHB_BASE, GPIO_PIN_4, &ui32Strength, &ui32PinType);
- GPIOPadConfigSet(GPIO_PORTF_AHB_BASE, GPIO_PIN_4,ui32Strength,GPIO_PIN_TYPE_STD);
- /*configure GPIO_PIN_1 on port N as std pin D4*/
- GPIOPadConfigGet(GPIO_PORTF_AHB_BASE, GPIO_PIN_0, &ui32Strength, &ui32PinType);
- GPIOPadConfigSet(GPIO_PORTF_AHB_BASE, GPIO_PIN_0,ui32Strength,GPIO_PIN_TYPE_STD);
- /* configure GPIO_PIN_0 on port J as button */
- GPIOPadConfigGet(GPIO_PORTJ_BASE, GPIO_PIN_0, &ui32Strength, &ui32PinType);
- GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0,ui32Strength,GPIO_PIN_TYPE_STD_WPU);
- /*set pin 1 of gpio port n to output*/
- //GPIOPinTypeGPIOOutput(GPIO_PORTJ_BASE,GPIO_PIN_0);
- GPIOPinWrite (GPIO_PORTJ_BASE, GPIO_PIN_0, 0x00000000);
- /* set pin 0 of gpio port j because button */
- //GPIOPinTypeGPIOOutput(GPIO_PORTJ_AHB_BASE,GPIO_PIN_0);
- for(;;) {
- if(GPIOPinRead(GPIO_PORTJ_BASE,GPIO_PIN_0) == 1) {
- GPIOPinTypeGPIOOutput(GPIO_PORTF_AHB_BASE,GPIO_PIN_4);
- GPIOPinWrite(GPIO_PORTF_AHB_BASE, GPIO_PIN_4, 0x00000010);
- }
- //for(ui32Loop = 0; ui32Loop < 400000; ui32Loop++){}
- }
- //GPIO_PORTF_AHB_BASE = GPIO_PORTJ_AHB_BASE;
- //Digital Enable for PortJ USR Switch1
- //GPIO_PORTJ_AHB_DEN_R = 0x01;
- //Enable Pull Up for PortJ USR Switch1
- //GPIO_PORTJ_AHB_PUR_R = 0x01;
- //for(;;) {
- // ui8val = ui8val ^ 2;/*toggle bit 1 in variable val*/
- /*write value of val to pin 1 of port n*/
- //GPIOPinWrite (GPIO_PORTF_AHB_BASE, GPIO_PIN_0, ui8val);
- // for(ui32Loop = 0; ui32Loop < 400000; ui32Loop++){}
- // SysCtlDelay(F_CPU/6); //approx 0,5 s
- //}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement