diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2014-06-29 12:34:32 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2014-06-29 12:34:32 +0300 |
| commit | c3e4c9a25c2910d2d66d52215b3406b13d5b23d5 (patch) | |
| tree | added370d1e356901f8579f076e3263fb0464db7 /boards/dk-tm4c129x/ble_btool/ble_btool.c | |
| parent | 990090a4cc9070837d31e66b58d40f0c3d038741 (diff) | |
Add more board models
Diffstat (limited to 'boards/dk-tm4c129x/ble_btool/ble_btool.c')
| -rw-r--r-- | boards/dk-tm4c129x/ble_btool/ble_btool.c | 283 |
1 files changed, 283 insertions, 0 deletions
diff --git a/boards/dk-tm4c129x/ble_btool/ble_btool.c b/boards/dk-tm4c129x/ble_btool/ble_btool.c new file mode 100644 index 0000000..88eb86b --- /dev/null +++ b/boards/dk-tm4c129x/ble_btool/ble_btool.c @@ -0,0 +1,283 @@ +//*****************************************************************************
+//
+// ble_btool.c - This simple program makes it possible to use BTool
+// to control a BLE device with TM4c129X + CC2540/CC2541EM
+// as host board.
+//
+// Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package.
+//
+//*****************************************************************************
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "inc/hw_ints.h"
+#include "inc/hw_memmap.h"
+#include "inc/hw_types.h"
+#include "driverlib/debug.h"
+#include "driverlib/gpio.h"
+#include "driverlib/interrupt.h"
+#include "driverlib/sysctl.h"
+#include "driverlib/uart.h"
+#include "driverlib/rom.h"
+#include "driverlib/rom_map.h"
+#include "driverlib/pin_map.h"
+#include "grlib/grlib.h"
+#include "drivers/kentec320x240x16_ssd2119.h"
+#include "drivers/frame.h"
+#include "drivers/pinout.h"
+
+//*****************************************************************************
+//
+//! \addtogroup example_list
+//! <h1>Bluetooth Low Energy ``BTool'' (ble_btool)</h1>
+//!
+//! This application connects the ICDI virtual UART0 with UART3, so that
+//! the BTool application running on PC can control the CC2540/CC2541 through
+//! the TM4C129X.
+//!
+//! The CC254X device should be programmed with HostTestRelease(Network
+//! Processor) application. A hex file containing this application can be
+//! found in the BLE stack 1.4.0 release under
+//! C:\\...\\BLE-CC254x-1.4.0\\Accessories\\HexFiles\\
+//! CC254X_SmartRF_HostTestRelease_All.hex. Please refer to the Bluetooth Low
+//! Energy CC254X Development Kit User's Guide for information on how to load
+//! the hex file to the CC254X. This User's Guide can be found in
+//! http://www.ti.com/lit/ug/swru301a/swru301a.pdf
+//!
+//! On the TM4C129X development board, make sure that jumpers PJ0 and PJ1
+//! are connected to the "EM_UART" side to ensure that the UART3 TX and RX
+//! signals are routed to the EM header. UART3 is used to communicate between
+//! the TM4C129X and the CC2540 device.
+//!
+//! BTool is a PC application that allows a user to form a connection between
+//! two BLE devices. For more details on BTool, please refer to the above
+//! User's Guide. The installer for BTool is included in the BLE stack 1.4.0
+//! release under C:\\...\\BLE-CC254x-1.4.0\\Accessories\\BTool\\
+//!
+//
+//*****************************************************************************
+
+//
+//*****************************************************************************
+//
+// The error routine that is called if the driver library encounters an error.
+//
+//*****************************************************************************
+#ifdef DEBUG
+void
+__error__(char *pcFilename, uint32_t ui32Line)
+{
+}
+#endif
+
+//*****************************************************************************
+//
+// The UART0 interrupt handler.
+//
+//*****************************************************************************
+void
+UART0IntHandler(void)
+{
+ uint32_t ui32Status;
+
+ //
+ // Get the interrrupt status.
+ //
+ ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
+
+ //
+ // Clear the asserted interrupts.
+ //
+ ROM_UARTIntClear(UART0_BASE, ui32Status);
+
+ //
+ // Loop while there are characters in the receive FIFO.
+ //
+ while(ROM_UARTCharsAvail(UART0_BASE))
+ {
+ //
+ // Read the next character from UART0 and sent it to UART3.
+ //
+ UARTCharPut(UART3_BASE, UARTCharGetNonBlocking(UART0_BASE));
+ }
+}
+
+//*****************************************************************************
+//
+// The UART3 interrupt handler.
+//
+//*****************************************************************************
+void
+UART3IntHandler(void)
+{
+ uint32_t ui32Status;
+
+ //
+ // Get the interrrupt status.
+ //
+ ui32Status = ROM_UARTIntStatus(UART3_BASE, true);
+
+ //
+ // Clear the asserted interrupts.
+ //
+ ROM_UARTIntClear(UART3_BASE, ui32Status);
+
+ //
+ // Loop while there are characters in the receive FIFO.
+ //
+ while(ROM_UARTCharsAvail(UART3_BASE))
+ {
+ //
+ // Read the next character from UART3 and send it to UART0.
+ //
+ ROM_UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART3_BASE));
+ }
+}
+
+//*****************************************************************************
+//
+// Send a string(HCI command) to the UART3.
+//
+//*****************************************************************************
+void
+UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
+{
+ //
+ // Loop while there are more characters to send.
+ //
+ while(ui32Count--)
+ {
+ //
+ // Write the next character to the UART.
+ //
+ ROM_UARTCharPutNonBlocking(UART3_BASE, *pui8Buffer++);
+ }
+}
+
+//*****************************************************************************
+//
+// This example demonstrates how to send a string of data to the UART.
+//
+//*****************************************************************************
+int
+main(void)
+{
+ uint32_t ui32SysClock;
+ tContext sContext;
+
+ //
+ // Run from the PLL at 120 MHz.
+ //
+ ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
+ SYSCTL_OSC_MAIN |
+ SYSCTL_USE_PLL |
+ SYSCTL_CFG_VCO_480), 120000000);
+
+ //
+ // Configure the device pins.
+ //
+ PinoutSet();
+
+ //
+ // Initialize the display driver.
+ //
+ Kentec320x240x16_SSD2119Init(ui32SysClock);
+
+ //
+ // Initialize the graphics context.
+ //
+ GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);
+
+ //
+ // Draw the application frame.
+ //
+ FrameDraw(&sContext, "ble-btool");
+
+ //
+ // PJ0, 1, 4, 5 are used for UART3.
+ //
+ ROM_GPIOPinConfigure(GPIO_PJ0_U3RX);
+ ROM_GPIOPinConfigure(GPIO_PJ1_U3TX);
+ ROM_GPIOPinConfigure(GPIO_PJ4_U3RTS);
+ ROM_GPIOPinConfigure(GPIO_PJ5_U3CTS);
+ ROM_GPIOPinTypeUART(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5);
+
+ //
+ // Display UART configuration on the display.
+ //
+ GrStringDraw(&sContext, "Use BTool on PC", -1, 70, 40, 0);
+ GrStringDraw(&sContext, "Port:", -1, 70, 70, 0);
+ GrStringDraw(&sContext, "Baud:", -1, 70, 95, 0);
+ GrStringDraw(&sContext, "Data:", -1, 70, 120, 0);
+ GrStringDraw(&sContext, "Parity:", -1, 70, 145, 0);
+ GrStringDraw(&sContext, "Stop:", -1, 70, 170, 0);
+ GrStringDraw(&sContext, "Flow:", -1, 70, 195, 0);
+ GrStringDraw(&sContext, "Uart 0", -1, 150, 70, 0);
+ GrStringDraw(&sContext, "115,200 bps", -1, 150, 95, 0);
+ GrStringDraw(&sContext, "8 Bit", -1, 150, 120, 0);
+ GrStringDraw(&sContext, "None", -1, 150, 145, 0);
+ GrStringDraw(&sContext, "1 Bit", -1, 150, 170, 0);
+ GrStringDraw(&sContext, "CTS/RTS", -1, 150, 195, 0);
+
+ //
+ // Enable the (non-GPIO) peripherals used by this example. PinoutSet()
+ // already enabled GPIO Port A.
+ //
+ ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
+ ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
+
+ //
+ // Enable processor interrupts.
+ //
+ IntMasterEnable();
+
+ //
+ // Configure the UART0 for 115,200, 8-N-1 operation.
+ //
+ ROM_UARTConfigSetExpClk(UART0_BASE, ui32SysClock, 115200,
+ (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
+ UART_CONFIG_PAR_NONE));
+
+ //
+ // Configure the UART3 for 115,200, 8-N-1 operation.
+ //
+ ROM_UARTConfigSetExpClk(UART3_BASE, ui32SysClock, 115200,
+ (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
+ UART_CONFIG_PAR_NONE));
+
+ //
+ // Configure the UART3 with flow control.
+ //
+ UARTFlowControlSet(UART3_BASE, UART_FLOWCONTROL_TX | UART_FLOWCONTROL_RX);
+
+ //
+ // Enable the UART interrupt.
+ //
+ ROM_IntEnable(INT_UART0);
+ ROM_IntEnable(INT_UART3);
+ ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
+ ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT);
+
+ //
+ // Loop forever passing data between UART0 and UART3.
+ //
+ while(1)
+ {
+ }
+}
|
