Commit 48a76249 authored by Matthias Wenzl's avatar Matthias Wenzl
Browse files

blink commit

parent 2928a6ec
/*! \file UIP_Task.c
\brief CCSv6 project using TI-RTOS and a custom network driver providing an ndk-less base environment
\author Matthias Wenzl
*/
/*
* ======== UIP_Task.c ========
*/
#include <stdbool.h>
#include <inc/hw_memmap.h>
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/Memory.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/*Board Header files */
#include <Blink_Task.h>
#include <Board.h>
#include <EK_TM4C1294XL.h>
#include <ctype.h>
#include <string.h>
/*
* ======== Blink ========
* Perform Blink Operation on led given at arg0
*/
void BlinkFxn(UArg arg0, UArg arg1)
{
led_descriptor_t *led_desc = (led_descriptor_t *)arg0;
uint32_t wait_ticks = (uint32_t) arg1;
/*gpio driverlib api uses same bit pattern for gpio mask and value*/
uint8_t ui8val = (uint8_t)led_desc->led;
while(1) {
ui8val ^= (uint8_t)led_desc->led;//initially off
GPIOPinWrite (led_desc->port_base, led_desc->led, ui8val);
Task_sleep(wait_ticks);
}
}
/*
* setup task function
*/
int setup_Blink_Task(led_descriptor_t *led_desc, uint32_t wait_ticks)
{
Task_Params taskLedParams;
Task_Handle taskLed;
uint32_t ui32Strength, ui32PinType;
Error_Block eb;
/*configure gpio port_base according to led*/
GPIOPadConfigGet(led_desc->port_base, led_desc->led, &ui32Strength, &ui32PinType);
GPIOPadConfigSet(led_desc->port_base, led_desc->led,ui32Strength,GPIO_PIN_TYPE_STD);
GPIOPinTypeGPIOOutput(led_desc->port_base, led_desc->led);
/* Create networking task with priority 15*/
Error_init(&eb);
Task_Params_init(&taskLedParams);
taskLedParams.stackSize = 1024;/*stack in bytes*/
taskLedParams.priority = 15;/*15 is default 16 is highest priority -> see RTOS configuration*/
taskLedParams.arg0 = (UArg) led_desc;/*pass led descriptor to arg0*/
taskLedParams.arg1 = (UArg) wait_ticks;
taskLed = Task_create((Task_FuncPtr)BlinkFxn, &taskLedParams, &eb);
if (taskLed == NULL) {
System_abort("TaskLed create failed");
}
return (0);
}
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
* *
*/ */
/* /*
* ======== StartBIOS.c ======== * ======== StartBIOS.c ========
*/ */
...@@ -38,7 +37,7 @@ ...@@ -38,7 +37,7 @@
#include <network_events.h> #include <network_events.h>
#include <UIP_Task.h> #include <Blink_Task.h>
...@@ -46,6 +45,7 @@ int main(void) ...@@ -46,6 +45,7 @@ int main(void)
{ {
uint32_t ui32SysClock; uint32_t ui32SysClock;
static led_descriptor_t led_desc;
/* Call board init functions. */ /* Call board init functions. */
ui32SysClock = Board_initGeneral(120*1000*1000); ui32SysClock = Board_initGeneral(120*1000*1000);
...@@ -61,9 +61,11 @@ int main(void) ...@@ -61,9 +61,11 @@ int main(void)
// UARTStdioConfig(0, 115200, ui32SysClock); // UARTStdioConfig(0, 115200, ui32SysClock);
/*Initialize UIP Stack - calls led_server, httpd or client depending on configuration of uip/uip-conf.h */ led_desc.port_base = GPIO_PORTN_BASE;
(void) setup_UIP_Task(ui32SysClock); led_desc.led = GPIO_PIN_1;
System_printf("Created UIP Task\n"); /*Initialize Blink Task*/
(void) setup_Blink_Task(&led_desc, 500);
System_printf("Created Blink Task\n");
/* SysMin will only print to the console upon calling flush or exit */ /* SysMin will only print to the console upon calling flush or exit */
......
...@@ -40,12 +40,6 @@ BIOS.libType = BIOS.LibType_Custom; ...@@ -40,12 +40,6 @@ BIOS.libType = BIOS.LibType_Custom;
BIOS.logsEnabled = true; BIOS.logsEnabled = true;
BIOS.assertsEnabled = true; BIOS.assertsEnabled = true;
/*** Network stack memory pool - fixed size head ***/
var heapBufParams = new HeapBuf.Params();
heapBufParams.blockSize = 1536;
heapBufParams.numBlocks = 8;
Program.global.cfg_netHeap = HeapBuf.create(heapBufParams);
/* ================ Driver configuration ================ */ /* ================ Driver configuration ================ */
var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS'); var TIRTOS = xdc.useModule('ti.tirtos.TIRTOS');
......
/*! \file Blink_Task.h
\brief Blink task
\author Matthias Wenzl
\author Michael Kramer
Blinking LED Task example.
*/
#include <stdbool.h>
#include <stdint.h>
/* Drivers Header files - fall back to driverlib for gpio*/
#include <driverlib/gpio.h>
#include <driverlib/pin_map.h>
#include <inc/hw_memmap.h>
#ifndef BLINK_TASK_H_
#define BLINK_TASK_H_
typedef struct {
uint32_t port_base;
uint8_t led;
}led_descriptor_t;
/*! \fn BlinkFxn
* \brief Execute Blink Task
*
*
* \param arg0 led descriptor struct
* \param arg1 Ticks to wait
*
*/
void BlinkFxn(UArg arg0, UArg arg1);
/*! \fn setup_Blink_Task
* \brief Setup Blink task
*
* Setup Blink task
* Task has highest priority and receives 1kB of stack
*
* \param led description.
* \param time wo wait in ticks for led to toggle
*
* \return always zero. In case of error the system halts.
*/
int setup_Blink_Task(led_descriptor_t *led_desc, uint32_t wait_ticks);
#endif /* UIP_TASK_H_ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment