Skip to content

Commit 6ba96d7

Browse files
author
Jenny Plunkett
committed
UART/Serial API stubs added, blinky still compiles 100%
1 parent f3d64a4 commit 6ba96d7

File tree

5 files changed

+190
-7
lines changed

5 files changed

+190
-7
lines changed

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/PeripheralNames.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,16 @@ extern "C" {
2525
// TODO
2626

2727
typedef enum {
28-
UART_0 = 0,
29-
UART_1 = 1,
30-
UART_2 = 2,
31-
UART_3 = 3,
32-
UART_4 = 4,
28+
// TODO: need to define peripherals in device/CC3220SF.h
29+
UART_0 = 0, //(int)CC3220SF_UART0_BASE,
30+
UART_1 = 1 //(int)CC3220SF_UART1_BASE,
3331
} UARTName;
3432

3533
typedef enum {
3634
ADC0_0 = 0,
3735
ADC0_1,
3836
ADC0_2,
39-
ADC0_3,
37+
ADC0_3
4038
} ADCName;
4139

4240
typedef enum {

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/PinNames.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ typedef enum {
106106

107107
// TODO: Use the right pin
108108
LED1 = P64,
109+
110+
// TODO: Use the right pins
111+
USBTX = P01,
112+
USBRX = P02,
113+
109114
// Not connected
110115
NC = (int)0xFFFFFFFF
111116
} PinName;

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/objects.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ typedef struct {
3131
PinDirection dir;
3232
} gpio_t;
3333

34+
struct serial_s {
35+
int index;
36+
};
37+
3438
#ifdef __cplusplus
3539
}
3640
#endif
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2006-2013 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
// math.h required for floating point operations for baud rate calculation
17+
#include <math.h>
18+
#include <stdio.h>
19+
#include <string.h>
20+
#include <stdlib.h>
21+
#include "mbed_assert.h"
22+
23+
#include "serial_api.h"
24+
#include "cmsis.h"
25+
#include "pinmap.h"
26+
#include "mbed_error.h"
27+
#include "gpio_api.h"
28+
29+
/******************************************************************************
30+
* INITIALIZATION
31+
******************************************************************************/
32+
#define UART_NUM 2
33+
34+
// http://dev.ti.com/tirex/content/simplelink_cc32xx_sdk_1_40_00_03/docs/tidrivers/doxygen/html/_u_a_r_t_c_c32_x_x_8h.html
35+
36+
static const PinMap PinMap_UART_TX[] = {
37+
{PIN_01, UART_1, 0},
38+
{PIN_03, UART_0, 0},
39+
{PIN_07, UART_1, 0},
40+
{PIN_16, UART_1, 0},
41+
{PIN_53, UART_0, 0},
42+
{PIN_55, UART_1, 0},
43+
{PIN_58, UART_1, 0},
44+
{PIN_62, UART_0, 0},
45+
{NC, NC, 0}
46+
};
47+
48+
static const PinMap PinMap_UART_RX[] = {
49+
{PIN_02, UART_1, 0},
50+
{PIN_04, UART_0, 0},
51+
{PIN_08, UART_1, 0},
52+
{PIN_17, UART_1, 0},
53+
{PIN_45, UART_0, 0},
54+
{PIN_45, UART_1, 0},
55+
{PIN_57, UART_0, 0},
56+
{PIN_57, UART_1, 0},
57+
{PIN_59, UART_1, 0},
58+
{NC, NC, 0}
59+
};
60+
61+
static const PinMap PinMap_UART_RTS[] = {
62+
{PIN_50, UART_0, 0},
63+
{PIN_50, UART_1, 0},
64+
{PIN_52, UART_0, 0},
65+
{PIN_61, UART_0, 0},
66+
{PIN_62, UART_0, 0},
67+
{PIN_62, UART_1, 0},
68+
{NC, NC, 0}
69+
};
70+
71+
static const PinMap PinMap_UART_CTS[] = {
72+
{PIN_50, UART_0, 0},
73+
{PIN_61, UART_0, 0},
74+
{PIN_61, UART_1, 0},
75+
{NC, NC, 0}
76+
};
77+
78+
static uart_irq_handler irq_handler;
79+
80+
int stdio_uart_inited = 0;
81+
serial_t stdio_uart;
82+
83+
struct serial_global_data_s {
84+
uint32_t serial_irq_id;
85+
gpio_t sw_rts, sw_cts;
86+
uint8_t count, rx_irq_set_flow, rx_irq_set_api;
87+
};
88+
89+
static struct serial_global_data_s uart_data[UART_NUM];
90+
91+
void serial_init(serial_t *obj, PinName tx, PinName rx) {
92+
int is_stdio_uart = 0;
93+
94+
// determine the UART to use
95+
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
96+
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
97+
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
98+
MBED_ASSERT((int)uart != NC);
99+
100+
// TODO
101+
}
102+
103+
void serial_free(serial_t *obj) {
104+
uart_data[obj->index].serial_irq_id = 0;
105+
}
106+
107+
// serial_baud
108+
// set the baud rate, taking in to account the current SystemFrequency
109+
void serial_baud(serial_t *obj, int baudrate) {
110+
// TODO
111+
}
112+
113+
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
114+
// TODO
115+
}
116+
117+
/******************************************************************************
118+
* INTERRUPTS HANDLING
119+
******************************************************************************/
120+
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {
121+
// TODO
122+
}
123+
124+
static void serial_irq_set_internal(serial_t *obj, SerialIrq irq, uint32_t enable) {
125+
// TODO
126+
}
127+
128+
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable) {
129+
// TODO
130+
}
131+
132+
static void serial_flow_irq_set(serial_t *obj, uint32_t enable) {
133+
// TODO
134+
}
135+
136+
/******************************************************************************
137+
* READ/WRITE
138+
******************************************************************************/
139+
int serial_getc(serial_t *obj) {
140+
// TODO
141+
return 1;
142+
}
143+
144+
void serial_putc(serial_t *obj, int c) {
145+
// TODO
146+
}
147+
148+
int serial_readable(serial_t *obj) {
149+
// TODO
150+
return 1;
151+
}
152+
153+
int serial_writable(serial_t *obj) {
154+
// TODO
155+
return 1;
156+
}
157+
158+
void serial_clear(serial_t *obj) {
159+
// TODO
160+
}
161+
162+
void serial_pinout_tx(PinName tx) {
163+
pinmap_pinout(tx, PinMap_UART_TX);
164+
}
165+
166+
void serial_break_set(serial_t *obj) {
167+
// TODO
168+
}
169+
170+
void serial_break_clear(serial_t *obj) {
171+
// TODO
172+
}
173+
174+
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow) {
175+
// TODO
176+
}

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,7 @@
42264226
"inherits": ["TI"],
42274227
"public": false,
42284228
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
4229-
"device_has": [],
4229+
"device_has": ["SERIAL"],
42304230
"release_versions": ["5"]
42314231
},
42324232
"CC3220SF": {

0 commit comments

Comments
 (0)