Commit ce0b80f8 authored by Michael Kramer's avatar Michael Kramer
Browse files

UART Task included

parent 8dfc5d72
/*! \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 ========
* ======== Blink_Task.c ========
*/
#include <stdbool.h>
#include <inc/hw_memmap.h>
......@@ -69,11 +61,9 @@ int setup_Blink_Task(led_descriptor_t *led_desc, uint32_t wait_ticks)
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*/
/* Create Blink task with priority 15*/
Error_init(&eb);
Task_Params_init(&taskLedParams);
taskLedParams.stackSize = 1024;/*stack in bytes*/
......
......@@ -23,9 +23,11 @@
#include <ti/sysbios/hal/Timer.h>
#include <ti/sysbios/knl/Event.h>
/* TI-RTOS Header files */
#include <ti/drivers/UART.h>
/* Drivers Header files*/
#include <ti/drivers/GPIO.h>
//#include <ti/drivers/GPIO.h>
/*Board Header files */
#include <Board.h>
......@@ -37,6 +39,7 @@
#include <Blink_Task.h>
#include <UART_Task.h>
......@@ -44,15 +47,10 @@ int main(void)
{
uint32_t ui32SysClock;
static led_descriptor_t led_desc;
static led_descriptor_t led_desc[2];
/* Call board init functions. */
ui32SysClock = Board_initGeneral(120*1000*1000);
// Uncomment this Section if you wan to use the UART for Output - it is tunneled via the Debuggger over USB
// GPIOPinConfigure(GPIO_PA0_U0RX);
// GPIOPinConfigure(GPIO_PA1_U0TX);
// GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Initialize the UART for console I/O.
......@@ -60,12 +58,21 @@ int main(void)
// UARTStdioConfig(0, 115200, ui32SysClock);
led_desc.port_base = GPIO_PORTN_BASE;
led_desc.led = GPIO_PIN_1;
/*Initialize Blink Task*/
(void) setup_Blink_Task(&led_desc, 500);
System_printf("Created Blink Task\n");
led_desc[0].port_base = GPIO_PORTN_BASE;
led_desc[0].led = GPIO_PIN_1;
/*Initialize+start Blink Task*/
(void) setup_Blink_Task(&led_desc[0], 500);
System_printf("Created Blink Task1\n");
led_desc[1].port_base = GPIO_PORTF_BASE;
led_desc[1].led = GPIO_PIN_0;
/*Initialize+start Blink Task*/
(void) setup_Blink_Task(&led_desc[1], 250);
System_printf("Created Blink Task2\n");
/*Initialize+start UART Task*/
(void) setup_UART_Task(0,0);
System_printf("Created UART Task\n");
/* SysMin will only print to the console upon calling flush or exit */
......
This diff is collapsed.
/*
* ======== UART_Task.c ========
* Author: Michael Kramer / Matthias Wenzl
*/
#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>
/* TI-RTOS Header files */
#include <driverlib/sysctl.h>
#include <driverlib/i2c.h>
#include <driverlib/ssi.h>
#include <driverlib/uart.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>
/*Board Header files */
#include <Blink_Task.h>
#include <Board.h>
#include <EK_TM4C1294XL.h>
#include <ctype.h>
#include <string.h>
/*
* ======== UART ========
* Echo Characters recieved and show reception on Port N Led 0
*/
void UARTFxn(UArg arg0, UArg arg1)
{
char input;
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 9600;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
System_abort("Error opening the UART");
}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */
while (1) {
UART_read(uart, &input, 1);
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 1);
UART_write(uart, &input, 1); //Remove this line to stop echoing!
Task_sleep(5);
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
}
}
/*
* setup task function
*/
int setup_UART_Task(led_descriptor_t *led_desc, uint32_t wait_ticks)
{
Task_Params taskUARTParams;
Task_Handle taskUART;
uint32_t ui32Strength, ui32PinType;
Error_Block eb;
/* Enable and configure the peripherals used by the UART0 */
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);
UART_init();
//Setup PortN LED1 activity signaling
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE,GPIO_PIN_0);
/* Create Blink task with priority 15*/
Error_init(&eb);
Task_Params_init(&taskUARTParams);
taskUARTParams.stackSize = 1024;/*stack in bytes*/
taskUARTParams.priority = 15;/*15 is default 16 is highest priority -> see RTOS configuration*/
taskUART = Task_create((Task_FuncPtr)UARTFxn, &taskUARTParams, &eb);
if (taskUART == NULL) {
System_abort("TaskUART create failed");
}
return (0);
}
/*
* Copyright (c) 2014, Texas Instruments Incorporated
* Copyright (c) 2015, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -34,7 +34,8 @@
*
* @brief EK_TM4C1294XL Board Specific APIs
*
* The EK_TM4C1294XL header file should be included in an application as follows:
* The EK_TM4C1294XL header file should be included in an application as
* follows:
* @code
* #include <EK_TM4C1294XL.h>
* @endcode
......@@ -49,41 +50,9 @@
extern "C" {
#endif
#include <ti/drivers/GPIO.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Event.h>
#include <Board.h>
#define ETH_USE_SEM 0
#define ETH_USE_EVENT 1
#define ETH_INIT_AND_RUN 0
#if(!(ETH_USE_SEM ^ ETH_USE_EVENT))
#error "Use either ETH_USE_SEM or ETH_USE_EVENT"
#endif
/*EMAC specifics*/
/*transmitter, receiver descriptor amount - 3 is the absolute minimum (see datahseet).
* increase with respect to available memory*/
/*However, due to internal uip stack operation concepts, only one 1536 byte long
* buffer will be used for transmission purposes*/
#define NUM_TX_DESCRIPTORS 3
#define NUM_RX_DESCRIPTORS 5
/* LEDs on EK_TM4C1294XL are active high. */
#define EK_TM4C1294XL_LED_OFF ( 0)
#define EK_TM4C1294XL_LED_ON (~0)
/* GPIO_Callbacks structure for GPIO interrupts */
/* handled by <Board.h>
* extern const GPIO_Callbacks EK_TM4C1294XL_gpioPortJCallbacks;
*
*/
#define EK_TM4C1294XL_LED_OFF (0)
#define EK_TM4C1294XL_LED_ON (1)
/*!
* @def EK_TM4C1294XL_EMACName
......@@ -100,10 +69,10 @@ typedef enum EK_TM4C1294XL_EMACName {
* @brief Enum of LED names on the EK_TM4C1294XL dev board
*/
typedef enum EK_TM4C1294XL_GPIOName {
EK_TM4C1294XL_D1 = 0,
EK_TM4C1294XL_D2,
EK_TM4C1294XL_USR_SW1,
EK_TM4C1294XL_USR_SW2,
EK_TM4C1294XL_USR_SW1 = 0,
EK_TM4C1294XL_USR_SW2,
EK_TM4C1294XL_D1,
EK_TM4C1294XL_D2,
EK_TM4C1294XL_GPIOCOUNT
} EK_TM4C1294XL_GPIOName;
......@@ -113,13 +82,21 @@ typedef enum EK_TM4C1294XL_GPIOName {
* @brief Enum of I2C names on the EK_TM4C1294XL dev board
*/
typedef enum EK_TM4C1294XL_I2CName {
EK_TM4C1294XL_I2C0 = 0,
EK_TM4C1294XL_I2C2,
EK_TM4C1294XL_I2C7,
EK_TM4C1294XL_I2C7 = 0,
EK_TM4C1294XL_I2C8,
EK_TM4C1294XL_I2CCOUNT
} EEK_TM4C1294XL_I2CName;
} EK_TM4C1294XL_I2CName;
/*!
* @def EK_TM4C1294XL_PWMName
* @brief Enum of PWM names on the EK_TM4C1294XL dev board
*/
typedef enum EK_TM4C1294XL_PWMName {
EK_TM4C1294XL_PWM0 = 0,
EK_TM4C1294XL_PWMCOUNT
} EK_TM4C1294XL_PWMName;
/*!
* @def EK_TM4C1294XL_SDSPIName
......@@ -149,9 +126,6 @@ typedef enum EK_TM4C1294XL_SPIName {
*/
typedef enum EK_TM4C1294XL_UARTName {
EK_TM4C1294XL_UART0 = 0,
EK_TM4C1294XL_UART2,
EK_TM4C1294XL_UART6,
EK_TM4C1294XL_UART7,
EK_TM4C1294XL_UARTCOUNT
} EK_TM4C1294XL_UARTName;
......@@ -195,67 +169,11 @@ typedef enum EK_TM4C1294XL_WiFiName {
EK_TM4C1294XL_WIFICOUNT
} EK_TM4C1294XL_WiFiName;
/*EMAC specific functions*/
/*initialize receive and transmit DMA descriptors*/
static void InitDescriptors(uint32_t ui32Base);
/*Ethernet Interrupt handler*/
void EthernetIntHandler(UArg arg);
/*
* @brief - Read a completely received ethernet frame
* @param - pointer to a variable holding the length of the received frame
* @return - pointer to the received frame
* */
uint8_t * PacketReceive(int32_t *len);
/*
* @brief - Write a complete frame to the transmit buffer in a blocking way (wait until a DMA descriptior is ready)
* @param *pui8Buf - pointer to a variable holding the frame
* @param i32BufLen - variable holding the length of the received frame
* @return - number of bytes sent
* */
int32_t PacketTransmit(uint8_t *pui8Buf, int32_t i32BufLen);
void FreeEmacRxBuf(void);
/* @brief - Initialize the EMAC core. Blocks until a link is established
* @param *mac_addr - a pointer to a buffer holding the to be configured mac address, if a NULL pointer is passed,
* the pre configured mac address is used, if non is found a NULL pointer is returned
* @return On success a semaphore handle which can be used to wait for a completely received frame in a task is returned
* otherwise a NULL pointer is returned
* */
#if ETH_USE_SEM
Semaphore_Handle EK_TM4C1294XL_initEMAC(uint32_t sysclock, uint8_t *mac_addr);
#endif
#if ETH_USE_EVENT
Event_Handle EK_TM4C1294XL_initEMAC(uint32_t sysclock, uint8_t *mac_addr);
#endif
#if !ETH_INIT_AND_RUN
/*
* @brief - a seperate start emac function in case ETH_INIT_AND_RUN is not defined
*
*/
void EK_TM4C1294XL_startEMAC(void);
#endif
/*
* @biref - get mac address from device
*
* @return - pointer to mac address buffer
*
*/
uint8_t * EK_TM4C1294XL_getMACAddr(void);
void EK_TM4C1294XL_initDMA(void);
/*!
* @brief Initialize the general board specific settings
*
* This function initializes the general board specific settings. This include
* This function initializes the general board specific settings.
* This includes:
* - Enable clock sources for peripherals
*/
extern uint32_t EK_TM4C1294XL_initGeneral(uint32_t sysclock);
......@@ -269,7 +187,7 @@ extern uint32_t EK_TM4C1294XL_initGeneral(uint32_t sysclock);
* The EMAC address is programmed as part of this call.
*
*/
//extern void EK_TM4C1294XL_initEMAC(void);
extern void EK_TM4C1294XL_initEMAC(void);
/*!
* @brief Initialize board specific GPIO settings
......@@ -277,7 +195,7 @@ extern uint32_t EK_TM4C1294XL_initGeneral(uint32_t sysclock);
* This function initializes the board specific GPIO settings and
* then calls the GPIO_init API to initialize the GPIO module.
*
* The GPIOs controlled by the GPIO module are determined by the GPIO_config
* The GPIOs controlled by the GPIO module are determined by the GPIO_PinConfig
* variable.
*/
extern void EK_TM4C1294XL_initGPIO(void);
......@@ -293,6 +211,17 @@ extern void EK_TM4C1294XL_initGPIO(void);
*/
extern void EK_TM4C1294XL_initI2C(void);
/*!
* @brief Initialize board specific PWM settings
*
* This function initializes the board specific PWM settings and then calls
* the PWM_init API to initialize the PWM module.
*
* The PWM peripherals controlled by the PWM module are determined by the
* PWM_config variable.
*/
extern void EK_TM4C1294XL_initPWM(void);
/*!
* @brief Initialize board specific SDSPI settings
*
......@@ -366,6 +295,9 @@ extern void EK_TM4C1294XL_initWatchdog(void);
*
* The hardware resources controlled by the WiFi module are determined by the
* WiFi_config variable.
*
* A SimpleLink CC3100 device or module is required and must be connected to
* use the WiFi driver.
*/
extern void EK_TM4C1294XL_initWiFi(void);
......
/*! \file UART_Task.h
\brief UART task
\author Matthias Wenzl
\author Michael Kramer
UART 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 UART_TASK_H_
#define UART_TASK_H_
/*! \fn UARTFxn
* \brief Execute UART Task
*
*
* \param arg0 void
* \param arg1 void
*
*/
void UARTFxn(UArg arg0, UArg arg1);
/*! \fn setup_UART_Task
* \brief Setup UART task
*
* Setup UART task
* Task has highest priority and receives 1kB of stack
*
* \return always zero. In case of error the system halts.
*/
int setup_UART_Task();
#endif
#
# This file was generated based on the configuration script:
# /home/matthias/workspace_v6_1/clp_rtos_network_raw/application.cfg
# /home/kramer/GIT_ROOT/connected_launchpad_rtos_raw/application.cfg
#
# This makefile may be included in other makefiles that need to build
# the libraries containing the compiled source files generated as
......@@ -14,7 +14,7 @@
#
# The absolute path to the generated source directory (at the time the
# sources were generated) is:
# /home/matthias/workspace_v6_1/clp_rtos_network_raw/src
# /home/kramer/GIT_ROOT/connected_launchpad_rtos_raw/src
#
GEN_SRC_DIR ?= ../src
......
XOPTS = -I"/home/matthias/ti/xdctools_3_31_01_33_core/packages/" -Dxdc_target_types__=/home/matthias/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M4F
XOPTS = -I"/home/kramer/ti/xdctools_3_31_01_33_core/packages/" -Dxdc_target_types__=/home/kramer/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M4F
vpath % /home/matthias/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/sysbios/
vpath %.c /home/matthias/ti/xdctools_3_31_01_33_core/packages/
vpath % /home/kramer/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/sysbios/
vpath %.c /home/kramer/ti/xdctools_3_31_01_33_core/packages/
CCOPTS = --endian=little -mv7M4 --abi=eabi --float_support=fpv4spd16 -q -ms --opt_for_speed=2 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U
XDC_ROOT = /home/matthias/ti/xdctools_3_31_01_33_core/packages/
XDC_ROOT = /home/kramer/ti/xdctools_3_31_01_33_core/packages/
BIOS_ROOT = /home/matthias/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/sysbios/
BIOS_ROOT = /home/kramer/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/ti/sysbios/
BIOS_DEFS = -Dti_sysbios_BIOS_swiEnabled__D=TRUE -Dti_sysbios_BIOS_taskEnabled__D=TRUE -Dti_sysbios_BIOS_clockEnabled__D=TRUE -Dti_sysbios_BIOS_runtimeCreatesEnabled__D=TRUE -Dti_sysbios_hal_Hwi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Swi_DISABLE_ALL_HOOKS -Dti_sysbios_knl_Task_DISABLE_ALL_HOOKS -Dti_sysbios_BIOS_smpEnabled__D=FALSE -Dti_sysbios_Build_useHwiMacros -Dti_sysbios_knl_Swi_numPriorities__D=16 -Dti_sysbios_knl_Task_deleteTerminatedTasks__D=FALSE -Dti_sysbios_knl_Task_numPriorities__D=16 -Dti_sysbios_knl_Task_checkStackFlag__D=TRUE -Dti_sysbios_knl_Clock_TICK_SOURCE=ti_sysbios_knl_Clock_TickSource_TIMER -Dti_sysbios_knl_Clock_TICK_MODE=ti_sysbios_knl_Clock_TickMode_PERIODIC -Dti_sysbios_hal_Core_delegate_getId=ti_sysbios_hal_CoreNull_getId__E -Dti_sysbios_hal_Core_delegate_interruptCore=ti_sysbios_hal_CoreNull_interruptCore__E -Dti_sysbios_hal_Core_delegate_lock=ti_sysbios_hal_CoreNull_lock__E -Dti_sysbios_hal_Core_delegate_unlock=ti_sysbios_hal_CoreNull_unlock__E -Dti_sysbios_hal_Core_numCores__D=1 -Dti_sysbios_hal_CoreNull_numCores__D=1 -Dti_sysbios_utils_Load_taskEnabled__D=TRUE -Dti_sysbios_utils_Load_swiEnabled__D=FALSE -Dti_sysbios_utils_Load_hwiEnabled__D=FALSE -Dti_sysbios_family_arm_m3_Hwi_dispatcherSwiSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherTaskSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherAutoNestingSupport__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_dispatcherIrpTrackingSupport__D=TRUE -Dti_sysbios_knl_Semaphore_supportsEvents__D=FALSE -Dti_sysbios_knl_Semaphore_supportsPriority__D=TRUE
BIOS_INC = -I"/home/matthias/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/"
BIOS_INC = -I"/home/kramer/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/"
TARGET_INC = -I"/home/matthias/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/"
TARGET_INC = -I"/home/kramer/ti/tirtos_tivac_2_14_00_10/products/bios_6_42_01_20/packages/"
INCS = $(BIOS_INC) $(TARGET_INC)
CC = /home/matthias/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armcl -c $(CCOPTS) -I /home/matthias/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include
ASM = /home/matthias/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armcl -c $(CCOPTS) -I /home/matthias/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include
AR = /home/matthias/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armar rq
CC = /home/kramer/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armcl -c $(CCOPTS) -I /home/kramer/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include
ASM = /home/kramer/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armcl -c $(CCOPTS) -I /home/kramer/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/include
AR = /home/kramer/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.2/bin/armar rq
DEL = rm -f
CP = cp -f
......
Supports Markdown
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