Skip to content

Commit

Permalink
Working on initial uart console
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldegrasse committed Aug 4, 2020
1 parent f1ed597 commit 7aeccc6
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 1 deletion.
15 changes: 14 additions & 1 deletion sd_logger.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,19 @@ Task.idleTaskStackSize = 512;
Task.numPriorities = 16;


/* ================ Task creation ================ */
/*
* Create all statically allocated tasks in this project.
*/
var Task = xdc.useModule('ti.sysbios.knl.Task');
/*
* Add all required tasks for this program.
*/
var uartTaskParams = new Task.Params();
uartTaskParams.stackSize = 512;
uartTaskParams.instance.name = "uartTask";
Program.global.uart_task = Task.create('&uartTaskEntry', uartTaskParams);


/* ================ Text configuration ================ */
var Text = xdc.useModule('xdc.runtime.Text');
Expand Down Expand Up @@ -536,4 +549,4 @@ driversConfig.libType = driversConfig.LibType_NonInstrumented;
/* ================ Application Specific Instances ================ */
/* ================ Application Specific Instances ================ */
66 changes: 66 additions & 0 deletions uart_console.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* @file uart_console.c
* Implements a UART console on the built in UART device, allowing for
* a user to view and manipulate the state of the logger.
*/

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/System.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

/* Board-specific functions */
#include "Board.h"

// UART configuration.
#define BAUD_RATE 115200
#define UART_DEV Board_UART0

UART_Handle uart;
UART_Params params;

/*
* PreOS Task for UART console. Sets up uart instance for data transmission,
* and creates UART console task.
* UART device on linux will be ttyACM0.
* This code MUST be called before the BIOS is started.
*/
void uart_prebios(void)
{
Board_initGPIO();
Board_initUART();
params.readDataMode = UART_DATA_BINARY;
params.writeDataMode = UART_DATA_BINARY;
// Block reads until newline received.
params.readReturnMode = UART_RETURN_NEWLINE;
// Echo all read characters back
params.readEcho = UART_ECHO_ON;
params.baudRate = BAUD_RATE;
uart = UART_open(UART_DEV, &params);
if (uart == NULL) {
System_abort("Error opening the UART device");
}
System_printf("Setup UART Device\n");
System_flush();
}


/*
* Task entry for the UART console handler. This task is created statically,
* see the "Task creation" section of the cfg file.
* @param arg0 unused
* @param arg1 unused
*/
void uartTaskEntry(UArg arg0, UArg arg1)
{
System_printf("UART task starting\n");
System_flush();
}

0 comments on commit 7aeccc6

Please sign in to comment.