Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdbool.h>
- #include <inc/hw_memmap.h>
- #include <xdc/std.h>
- #include <xdc/runtime/System.h>
- #include <xdc/runtime/Error.h>
- #include <ti/sysbios/BIOS.h>
- #include <ti/sysbios/knl/Clock.h>
- #include <ti/sysbios/knl/Task.h>
- #include <ti/sysbios/knl/Event.h>
- #include <ti/sysbios/knl/Semaphore.h>
- #include <driverlib/gpio.h>
- #include <driverlib/pin_map.h>/*supplies GPIO_PIN_x*/
- #include <driverlib/sysctl.h>
- Void clockfnc();
- void blinkled();
- Event_Handle eventtrg;
- /*
- * ======== main ========
- */
- Int main()
- {
- Clock_Params clkParams;
- Task_Params tskParams;
- SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
- GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
- GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_0);
- GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0x00);
- Error_Block eb;
- Error_init(&eb);
- eventtrg = Event_create(NULL, &eb);
- if (eventtrg == NULL) {
- System_abort("Event create failed");
- }
- /* Create a periodic Clock Instance with period = 1000 system time units */
- Clock_Params_init(&clkParams);
- clkParams.period = 1000;
- clkParams.startFlag = TRUE;
- Clock_create(clockfnc, 1000, &clkParams, NULL);
- /* create a ledblink task */
- Task_Params_init(&tskParams);
- tskParams.priority = 15;
- tskParams.arg0 = NULL;
- Task_create(blinkled, &tskParams, NULL);
- BIOS_start(); /* does not return */
- return(0);
- }
- /*
- * ======== clockfnc =======
- */
- Void clockfnc()
- {
- /* Explicit posting of Event_Id_00 by calling Event_post() */
- Event_post(eventtrg, Event_Id_00);
- }
- void blinkled()
- {
- static uint8_t ui8val = 0;
- UInt res;
- for (;;) {
- res = Event_pend(eventtrg,Event_Id_00,Event_Id_00,NULL);
- if (res != 0)
- ui8val=ui8val ^ 1;
- GPIOPinWrite (GPIO_PORTF_BASE, GPIO_PIN_0, ui8val);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement