Commit 1ff35de5 authored by Theodor-Adrian Stana's avatar Theodor-Adrian Stana

Merge branch 'thedi-sw-dev' of ohwr.org:freewatch into thedi-sw-dev

parents 90d7d4de 71894dcb
Cmp-Mod V01 Created by Cvpcb (2014-05-28 BZR 4896)-product date = Sun 01 Jun 2014 04:25:04 PM CEST
BeginCmp
TimeStamp = /537A663F/53821E01;
Reference = ANT1;
ValeurCmp = W3011A;
IdModule = freewatch_footprints:ANTENNA_W3011A;
EndCmp
Cmp-Mod V01 Created by Cvpcb (2014-06-01 BZR 4909)-product date = Thu 26 Jun 2014 07:54:17 PM CEST
BeginCmp
TimeStamp = /537A65FD/537BB217;
......@@ -64,9 +57,9 @@ IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C4A70;
TimeStamp = /537A65FD/539156F2;
Reference = C9;
ValeurCmp = 56pF;
ValeurCmp = 1uF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
......@@ -74,27 +67,27 @@ BeginCmp
TimeStamp = /537A663F/537C472A;
Reference = C10;
ValeurCmp = NM;
IdModule = Capacitors_SMD:c_0603;
IdModule = Capacitors_SMD:c_0402;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C4796;
Reference = C11;
ValeurCmp = NM;
IdModule = Capacitors_SMD:c_0603;
IdModule = Capacitors_SMD:c_0402;
EndCmp
BeginCmp
TimeStamp = /537A663F/53820BAE;
Reference = C12;
ValeurCmp = 100pF;
ValeurCmp = 22pF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53820B46;
Reference = C13;
ValeurCmp = 33nF;
ValeurCmp = 22pF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
......@@ -108,28 +101,28 @@ EndCmp
BeginCmp
TimeStamp = /537A663F/537C5505;
Reference = C15;
ValeurCmp = 10uF;
ValeurCmp = 2.2uF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C5493;
Reference = C16;
ValeurCmp = 100nF;
ValeurCmp = 22pF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C56B6;
TimeStamp = /537A65FD/53915705;
Reference = C17;
ValeurCmp = 4.7uF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C56DE;
TimeStamp = /537A662B/539B77D9;
Reference = C18;
ValeurCmp = 100nF;
ValeurCmp = 10pF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
......@@ -168,6 +161,13 @@ ValeurCmp = 100nF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/539B7866;
Reference = C24;
ValeurCmp = 10pF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537CF915;
Reference = C25;
......@@ -175,6 +175,13 @@ ValeurCmp = 100nF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53AA03F1;
Reference = C26;
ValeurCmp = 10uF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53831B91;
Reference = C27;
......@@ -316,17 +323,10 @@ IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537F02DF;
Reference = D1;
ValeurCmp = CDBU0130R;
IdModule = freewatch_footprints:d_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537F01F9;
Reference = D2;
ValeurCmp = CDBU0130R;
IdModule = freewatch_footprints:d_0603;
TimeStamp = /537A663F/53AB6B0D;
Reference = C47;
ValeurCmp = 100nF;
IdModule = Capacitors_SMD:c_0603;
EndCmp
BeginCmp
......@@ -364,6 +364,13 @@ ValeurCmp = LED_STD;
IdModule = LEDs:LED-0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/5390F7CE;
Reference = L1;
ValeurCmp = IND;
IdModule = Capacitors_SMD:c_0402;
EndCmp
BeginCmp
TimeStamp = /537A65FD/537A6938;
Reference = P1;
......@@ -375,21 +382,35 @@ BeginCmp
TimeStamp = /537A65FD/537A6E8C;
Reference = P3;
ValeurCmp = CONN_2;
IdModule = freewatch_footprints:78171-0002;
IdModule = freewatch_footprints:SMD_BAT_CONN;
EndCmp
BeginCmp
TimeStamp = /537A663F/53831BA5;
Reference = P6;
ValeurCmp = CONN_2;
IdModule = freewatch_footprints:78171-0002;
IdModule = freewatch_footprints:CONN_1MM_2P;
EndCmp
BeginCmp
TimeStamp = /537A662B/5382C001;
Reference = P7;
ValeurCmp = CONN_6;
IdModule = freewatch_footprints:78171-5006;
IdModule = Connect:SIL-6;
EndCmp
BeginCmp
TimeStamp = /537A663F/539134C1;
Reference = Q1;
ValeurCmp = BSS138;
IdModule = Transistors_SMD:sot23;
EndCmp
BeginCmp
TimeStamp = /537A663F/53914EE0;
Reference = Q2;
ValeurCmp = BSS138;
IdModule = Transistors_SMD:sot23;
EndCmp
BeginCmp
......@@ -406,6 +427,13 @@ ValeurCmp = 100k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/539168AA;
Reference = R3;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A65FD/537BB4BE;
Reference = R4;
......@@ -449,37 +477,37 @@ IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C46E1;
TimeStamp = /537A663F/539167ED;
Reference = R10;
ValeurCmp = 0;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C4AEB;
Reference = R11;
ValeurCmp = 100;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C4B8B;
Reference = R12;
ValeurCmp = 100;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/537EA484;
Reference = R13;
ValeurCmp = 470k;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/537D2BE4;
TimeStamp = /537A663F/53A9F0B3;
Reference = R14;
ValeurCmp = 4k7;
ValeurCmp = 10R;
IdModule = freewatch_footprints:r_0603;
EndCmp
......@@ -500,28 +528,28 @@ EndCmp
BeginCmp
TimeStamp = /537A662B/5383BD39;
Reference = R17;
ValeurCmp = 100k;
ValeurCmp = 91R;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/5383BE91;
Reference = R18;
ValeurCmp = 100k;
ValeurCmp = 91R;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/5383BECD;
Reference = R19;
ValeurCmp = 100k;
ValeurCmp = 91R;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/5383BF0A;
Reference = R20;
ValeurCmp = 100k;
ValeurCmp = 91R;
IdModule = freewatch_footprints:r_0603;
EndCmp
......@@ -529,14 +557,14 @@ BeginCmp
TimeStamp = /537A662B/537D2D0A;
Reference = R21;
ValeurCmp = 15R;
IdModule = freewatch_footprints:r_0603;
IdModule = Capacitors_SMD:c_0402;
EndCmp
BeginCmp
TimeStamp = /537A662B/537D2D6B;
Reference = R22;
ValeurCmp = 15R;
IdModule = freewatch_footprints:r_0603;
IdModule = Capacitors_SMD:c_0402;
EndCmp
BeginCmp
......@@ -581,6 +609,27 @@ ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53914EDA;
Reference = R29;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53914ED3;
Reference = R30;
ValeurCmp = 10k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A663F/53AA0E8E;
Reference = R31;
ValeurCmp = 100k;
IdModule = freewatch_footprints:r_0603;
EndCmp
BeginCmp
TimeStamp = /537A662B/5383CD4E;
Reference = SP1;
......@@ -591,28 +640,28 @@ EndCmp
BeginCmp
TimeStamp = /537A662B/5383007F;
Reference = SW1;
ValeurCmp = SW_PUSH;
ValeurCmp = EVQ-P4MB3K;
IdModule = freewatch_footprints:SWITCH_EVQP4;
EndCmp
BeginCmp
TimeStamp = /537A662B/538300B0;
Reference = SW2;
ValeurCmp = SW_PUSH;
ValeurCmp = EVQ-P4MB3K;
IdModule = freewatch_footprints:SWITCH_EVQP4;
EndCmp
BeginCmp
TimeStamp = /537A662B/538300E1;
Reference = SW3;
ValeurCmp = SW_PUSH;
ValeurCmp = EVQ-P4MB3K;
IdModule = freewatch_footprints:SWITCH_EVQP4;
EndCmp
BeginCmp
TimeStamp = /537A662B/53830112;
Reference = SW4;
ValeurCmp = SW_PUSH;
ValeurCmp = EVQ-P4MB3K;
IdModule = freewatch_footprints:SWITCH_EVQP4;
EndCmp
......@@ -645,17 +694,17 @@ IdModule = freewatch_footprints:TDFN-10;
EndCmp
BeginCmp
TimeStamp = /537A663F/537C45EB;
TimeStamp = /537A65FD/539156EB;
Reference = U5;
ValeurCmp = MAX2659;
IdModule = freewatch_footprints:UDFN6;
ValeurCmp = TPS780180300;
IdModule = freewatch_footprints:SON-6;
EndCmp
BeginCmp
TimeStamp = /537A663F/537A7ED7;
TimeStamp = /537A663F/5390DC07;
Reference = U6;
ValeurCmp = L70;
IdModule = freewatch_footprints:GPS_L70;
ValeurCmp = M10478-A1;
IdModule = freewatch_footprints:M10478-A1;
EndCmp
BeginCmp
......@@ -673,10 +722,10 @@ IdModule = freewatch_footprints:LFCSP_8L;
EndCmp
BeginCmp
TimeStamp = /537A663F/537E7255;
TimeStamp = /537A663F/53AB496F;
Reference = U9;
ValeurCmp = ADP198;
IdModule = freewatch_footprints:LFCSP_8L;
ValeurCmp = SST25WF040B;
IdModule = freewatch_footprints:USON_2X3;
EndCmp
BeginCmp
......@@ -724,8 +773,15 @@ EndCmp
BeginCmp
TimeStamp = /537A662B/537FC26F;
Reference = X1;
ValeurCmp = CRYSTAL_SMD;
ValeurCmp = 32.768kHz;
IdModule = freewatch_footprints:AB26TRB;
EndCmp
BeginCmp
TimeStamp = /537A662B/539B6F18;
Reference = X2;
ValeurCmp = 48MHz;
IdModule = freewatch_footprints:ABM11_CRYSTAL;
EndCmp
EndListe
This diff is collapsed.
This diff is collapsed.
update=Tue 27 May 2014 10:54:59 PM CEST
update=Wed 02 Jul 2014 11:58:45 PM CEST
version=1
last_client=kicad
[cvpcb]
......
This diff is collapsed.
This diff is collapsed.
......@@ -450,7 +450,7 @@ t_PRECHG = K_TMR * R_TMR\nt_MAXCHG = 10 * K_TMR * R_TMR\nK_TMR = 48 s/kohm
Text Notes 3050 4200 0 40 ~ 0
I_CHG = K_ISET / R_ISET\nK_ISET = 890 A*ohm
Text Notes 10350 3250 0 50 ~ 10
VCC = 3V
VCC = 3V, 150mA
Text Notes 600 1200 0 50 ~ 0
Copyright Julian Lewis 2014.\nThis documentation describes Open Hardware and is licensed under the\nCERN OHL v. 1.2.\nYou may redistribute and modify this documentation under the terms of the\nCERN OHL v.1.2. (http://ohwr.org/cernohl). This documentation is distributed\nWITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING OF MERCHANTABILITY,\nSATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE.\nPlease see the CERN OHL v.1.2 for applicable conditions
$Comp
......@@ -728,7 +728,7 @@ Wire Wire Line
Text Notes 5200 2650 0 60 ~ 12
Battery charger
Text Notes 8350 3050 0 60 ~ 12
LDO voltage regulator
System LDO voltage regulator
Text Notes 5250 4700 0 60 ~ 12
Battery fuel gauge
Text Notes 2200 2250 0 60 ~ 12
......@@ -813,6 +813,141 @@ Wire Wire Line
Wire Wire Line
9350 3650 9450 3650
Connection ~ 9450 3650
Text Notes 8350 4100 0 60 ~ 0
TPS73430 is pin compatible and 250mA
Text Notes 7900 4100 0 60 ~ 0
Alternative: TPS73430 (pin compatible, 250mA)
$Comp
L TPS780180300 U5
U 1 1 539156EB
P 8250 2000
F 0 "U5" H 8800 2150 60 0000 C CNN
F 1 "TPS780180300" H 8800 1450 60 0000 C CNN
F 2 "" H 8250 2000 60 0000 C CNN
F 3 "" H 8250 2000 60 0000 C CNN
1 8250 2000
1 0 0 -1
$EndComp
$Comp
L CAP C9
U 1 1 539156F2
P 7950 2100
F 0 "C9" V 7900 2150 39 0000 C CNN
F 1 "1uF" V 8000 2200 39 0000 C CNN
F 2 "" H 7950 2100 60 0000 C CNN
F 3 "" H 7950 2100 60 0000 C CNN
1 7950 2100
0 1 1 0
$EndComp
$Comp
L GND #PWR020
U 1 1 539156F9
P 7950 2250
F 0 "#PWR020" H 7950 2250 30 0001 C CNN
F 1 "GND" H 7950 2180 30 0001 C CNN
F 2 "" H 7950 2250 60 0000 C CNN
F 3 "" H 7950 2250 60 0000 C CNN
1 7950 2250
1 0 0 -1
$EndComp
$Comp
L GND #PWR021
U 1 1 539156FF
P 8150 2450
F 0 "#PWR021" H 8150 2450 30 0001 C CNN
F 1 "GND" H 8150 2380 30 0001 C CNN
F 2 "" H 8150 2450 60 0000 C CNN
F 3 "" H 8150 2450 60 0000 C CNN
1 8150 2450
1 0 0 -1
$EndComp
$Comp
L CAP C17
U 1 1 53915705
P 9650 2150
F 0 "C17" V 9600 2200 39 0000 C CNN
F 1 "4.7uF" V 9700 2250 39 0000 C CNN
F 2 "" H 9650 2150 60 0000 C CNN
F 3 "" H 9650 2150 60 0000 C CNN
1 9650 2150
0 1 1 0
$EndComp
$Comp
L GND #PWR022
U 1 1 5391570C
P 9650 2300
F 0 "#PWR022" H 9650 2300 30 0001 C CNN
F 1 "GND" H 9650 2230 30 0001 C CNN
F 2 "" H 9650 2300 60 0000 C CNN
F 3 "" H 9650 2300 60 0000 C CNN
1 9650 2300
1 0 0 -1
$EndComp
Wire Wire Line
7950 2200 7950 2250
Wire Wire Line
8250 2300 8150 2300
Wire Wire Line
8150 2300 8150 2450
Wire Wire Line
9350 2000 9650 2000
Wire Wire Line
8250 2200 8150 2200
Wire Wire Line
8150 2200 8150 2000
Connection ~ 8150 2000
Wire Wire Line
9650 1950 9650 2050
Connection ~ 9650 2000
Wire Wire Line
9650 2250 9650 2300
Connection ~ 7950 2000
Text Notes 8350 1700 0 60 ~ 12
GPS module LDO voltage regulator
Wire Wire Line
8250 2400 8150 2400
Connection ~ 8150 2400
Wire Wire Line
7650 2000 8250 2000
$Comp
L +1.8V #PWR023
U 1 1 53915721
P 9650 1950
F 0 "#PWR023" H 9650 2090 20 0001 C CNN
F 1 "+1.8V" H 9650 2060 30 0000 C CNN
F 2 "" H 9650 1950 60 0000 C CNN
F 3 "" H 9650 1950 60 0000 C CNN
1 9650 1950
1 0 0 -1
$EndComp
Wire Wire Line
9450 2150 9450 2200
Wire Wire Line
9450 2200 9350 2200
$Comp
L +VIN #PWR024
U 1 1 53A9EA44
P 7400 3300
F 0 "#PWR024" H 7400 3440 20 0001 C CNN
F 1 "+VIN" H 7400 3410 30 0000 C CNN
F 2 "" H 7400 3300 60 0000 C CNN
F 3 "" H 7400 3300 60 0000 C CNN
1 7400 3300
1 0 0 -1
$EndComp
Wire Wire Line
7400 3300 7400 3350
Connection ~ 7400 3350
Wire Wire Line
7650 2000 7650 3350
Connection ~ 7650 3350
$Comp
L +VIN #PWR025
U 1 1 53AC8248
P 9450 2150
F 0 "#PWR025" H 9450 2290 20 0001 C CNN
F 1 "+VIN" H 9450 2260 30 0000 C CNN
F 2 "" H 9450 2150 60 0000 C CNN
F 3 "" H 9450 2150 60 0000 C CNN
1 9450 2150
1 0 0 -1
$EndComp
$EndSCHEMATC
......@@ -10,7 +10,7 @@
####################################################################
DEVICE = EFM32GG330F1024
PROJECTNAME = freertos_blink
PROJECTNAME = uart_test
# Name of interface configuration file used by OpenOCD
OOCD_IFACE ?= stlink-v2-1
......@@ -131,7 +131,8 @@ C_SRC += \
../../common/emlib/src/em_rmu.c \
../../common/emlib/src/em_rtc.c \
../../common/emlib/src/em_system.c \
../.../common/emlib/src/em_usart.c \
../../common/emlib/src/em_usart.c \
../../common/emlib/src/em_leuart.c \
../../common/emdrv/sleep/src/sleep.c \
../uart/uart.c \
../main.c
......
......@@ -32,16 +32,18 @@
* last changes:
* 2014-07-07 Theodor Stana t.stana@cern.ch File created
*==============================================================================
* TODO: -
* TODO: -
*==============================================================================
*/
#include "uart.h"
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
uint32_t msticks = 0;
char str[32];
void SysTick_Handler()
{
......@@ -58,16 +60,21 @@ void delay(uint32_t n)
int main()
{
uart_init();
/* Setup SysTick Timer for 1 msec interrupts */
if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1);
CMU_ClockEnable(cmuClock_HFPER, true);
uart_init(4800, 8, "n", "2");
GPIO_PinModeSet(gpioPortD, 1, gpioModePushPull, 0);
while (1)
{
uart_puts("supercalifrageristic\n");
if (uart_gets(str))
uart_puts(str);
// uart_puts("supercalifrageristic\r\n");
GPIO_PinOutToggle(gpioPortD, 1);
delay(500);
}
}
......@@ -36,15 +36,31 @@
*==============================================================================
*/
#include <string.h>
#include "uart.h"
#include "em_cmu.h"
#include "em_int.h"
#include "em_gpio.h"
#if defined(UART_USE_USART)
#include "em_usart.h"
#else
#include "em_leuart.h"
#endif
#define RXBUFSIZE 32
static volatile uint8_t rxbuf[RXBUFSIZE];
static volatile int widx = 0;
static volatile int ridx = 0;
static volatile int rxcnt = 0;
static volatile int rxovf = 0;
/*
*==============================================================================
* UART initialization
* UART IRQ for data reception
*
* params:
* * none
......@@ -53,12 +69,98 @@
* * none
*
* comments:
* Receives data and stores it in a buffer for later readout
*
*==============================================================================
*/
void UART_IRQ_NAME()
{
#if defined(UART_USE_USART)
if (UART_PORT->STATUS & USART_STATUS_RXDATAV)
#else
if (UART_PORT->IF & LEUART_IF_RXDATAV)
#endif
{
if (rxovf == 0)
{
rxbuf[widx] = UART_RX(UART_PORT);
widx++;
rxcnt++;
if (widx == RXBUFSIZE)
{
widx = 0;
}
if (rxcnt > RXBUFSIZE)
{
rxovf = 1;
}
}
}
}
/*
*==============================================================================
* UART initialization
*
* params:
* * baud -- integer baud rate
* * databits -- integer number of data bits
* USART: 4-16
* LEUART: 8 or 9
* * parity -- "n" == none
* "e" == even
* "o" == odd
* * stopbits -- "0.5"/"1"/"1.5"/"2"
*
* returns:
* * none
*
* comments:
* Initializes UART library for selected UART
*
*==============================================================================
*/
void uart_init()
void uart_init(int baud, int databits, char *parity, char *stopbits)
{
/* First, adjust the init struct according to params */
#if defined(UART_USE_USART)
USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;
init.baudrate = baud;
init.databits = databits - 3;
if (strcmp(parity, "n") == 0)
init.parity = usartNoParity;
else if (strcmp(parity, "e") == 0)
init.parity = usartEvenParity;
else if (strcmp(parity, "o") == 0)
init.parity = usartOddParity;
if (strcmp(stopbits, "0.5") == 0)
init.stopbits = usartStopbits0p5;
else if (strcmp(stopbits, "1") == 0)
init.stopbits = usartStopbits1;
else if (strcmp(stopbits, "1.5") == 0)
init.stopbits = usartStopbits1p5;
else if (strcmp(stopbits, "2") == 0)
init.stopbits = usartStopbits2;
#else
LEUART_Init_TypeDef init = LEUART_INIT_DEFAULT;
//
//
//
//
//
// SAME AS ABOVE FOR LEUART
//
//
//
//
//
#endif
/* Now, the rest of the init sequence */
#if defined(UART_USE_USART)
/* Configure GPIO pins */
CMU_ClockEnable(cmuClock_GPIO, true);
......@@ -66,19 +168,16 @@ void uart_init()
GPIO_PinModeSet(UART_TXPORT, UART_TXPIN, gpioModePushPull, 1);
GPIO_PinModeSet(UART_RXPORT, UART_RXPIN, gpioModeInput, 0);
USART_TypeDef *usart = UART_PORT;
USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;
/* Enable peripheral clocks */
CMU_ClockEnable(cmuClock_HFPER, true);
CMU_ClockEnable(UART_CLK, true);
/* Configure USART for basic async operation */
init.enable = usartDisable;
USART_InitAsync(usart, &init);
USART_InitAsync(UART_PORT, &init);
/* Enable pins at UART1 location #2 */
usart->ROUTE = USART_ROUTE_RXPEN | USART_ROUTE_TXPEN | UART_LOC;
UART_PORT->ROUTE = USART_ROUTE_RXPEN | USART_ROUTE_TXPEN | UART_LOC;
/* Clear previous RX interrupts */
USART_IntClear(UART_PORT, USART_IF_RXDATAV);
......@@ -89,7 +188,37 @@ void uart_init()
NVIC_EnableIRQ(UART_IRQN);
/* Finally enable it */
USART_Enable(usart, usartEnable);
USART_Enable(UART_PORT, usartEnable);
#else
/* Enable CORE LE clock in order to access LE modules */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Select LFXO for LEUARTs (and wait for it to stabilize) */
CMU_ClockSelectSet(cmuClock_LFB, cmuSelect_LFXO);
CMU_ClockEnable(UART_CLK, true);
/* Do not prescale clock */
CMU_ClockDivSet(UART_CLK, cmuClkDiv_1);
/* Configure LEUART */
init.enable = leuartDisable;
LEUART_Init(UART_PORT, &init);
/* Enable pins at default location */
UART_PORT->ROUTE = LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN | UART_LOC;
/* Clear previous RX interrupts */
LEUART_IntClear(UART_PORT, LEUART_IF_RXDATAV);
NVIC_ClearPendingIRQ(UART_IRQN);
/* Enable RX interrupts */
LEUART_IntEnable(UART_PORT, LEUART_IF_RXDATAV);
NVIC_EnableIRQ(UART_IRQN);
/* Finally enable it */
LEUART_Enable(UART_PORT, leuartEnable);
#endif
}
/*
......@@ -110,7 +239,7 @@ void uart_init()
*/
void uart_putc(char c)
{
USART_Tx(UART_PORT, c);
UART_TX(UART_PORT, c);
}
/*
......@@ -133,7 +262,7 @@ void uart_putc(char c)
int uart_puts(char *s)
{
int nc = 0;
for (; *s == '\0'; *s++)
for ( ; *s != '\0'; *s++)
{
uart_putc(*s);
nc++;
......@@ -141,3 +270,71 @@ int uart_puts(char *s)
return nc;
}
/*
*==============================================================================
* Receive character
*
* params:
* * none
*
* returns:
* * character in buffer
*
* comments:
* Retrieves data from the receive buffer, which is filled in the ISR above
*
*==============================================================================
*/
char uart_getc()
{
char c = '\0';
INT_Disable();
if (rxcnt > 0)
{
c = rxbuf[ridx++];
if (ridx == RXBUFSIZE)
{
ridx = 0;
}
rxcnt--;
rxovf = 0;
}
INT_Enable();
return c;
}
/*
*==============================================================================
* Read a set of characters from UART buffer
*
* params:
* * buffer to write to
*
* returns:
* * number of characters read
*
* comments:
* Replica of stdlib gets. Returns characters from the UART buffers until
* the null character or a line break character is encountered. The latter,
* if encountered, is replaced with a null character.
*
*==============================================================================
*/
int uart_gets(char *s)
{
uint32_t nc = 0;
do {
*s = uart_getc();
if (*s == '\n')
*s = '\0';
if (*s == '\0')
break;
nc++;
*s++;
} while (1);
return nc;
}
......@@ -46,23 +46,48 @@
/*============================================================================*/
/* Defines */
/*============================================================================*/
#define UART_IRQ_NAME USART0_RX_IRQHandler
#define UART_CLK cmuClock_USART1
#define UART_IRQN USART0_RX_IRQn
#define UART_PORT USART0
#define UART_TX USART_Tx
#define UART_RX USART_Rx
#define UART_LOC USART_ROUTE_LOCATION_LOC0
#define UART_TXPORT gpioPortE
#define UART_TXPIN 10
#define UART_RXPORT gpioPortE
#define UART_RXPIN 11
/* Use USART/LEUART definition; no UART for EFM32GG330, thus not supported */
/* Should be mutually exclusive, else compilation error */
#define UART_USE_USART
//#define UART_USE_LEUART
/* Change the definition files below according to the port you use */
#if defined(UART_USE_USART)
#define UART_PORT USART0
#define UART_IRQ_NAME USART0_RX_IRQHandler
#define UART_CLK cmuClock_USART0
#define UART_IRQN USART0_RX_IRQn
#define UART_TX USART_Tx
#define UART_RX USART_Rx
#define UART_TXPORT gpioPortE
#define UART_TXPIN 10
#define UART_RXPORT gpioPortE
#define UART_RXPIN 11
#define UART_LOC USART_ROUTE_LOCATION_LOC0
#endif
#if defined(UART_USE_LEUART)
#define UART_PORT LEUART1
#define UART_IRQ_NAME LEUART1_IRQHandler
#define UART_CLK cmuClock_LEUART1
#define UART_IRQN LEUART1_IRQn
#define UART_UART LEUART1
#define UART_TX LEUART_Tx
#define UART_RX LEUART_Rx
#define UART_TXPORT gpioPortC
#define UART_TXPIN 6
#define UART_RXPORT gpioPortC
#define UART_RXPIN 7
#define UART_LOC LEUART_ROUTE_LOCATION_LOC0
#endif
/*============================================================================*/
/* Function prototypes */
/*============================================================================*/
void uart_init();
void uart_init(int baud, int databits, char *parity, char *stopbits);
void uart_putc(char c);
int uart_puts(char *s);
char uart_getc();
int uart_gets(char *s);
#endif // __FRW_UART_H_
#endif // __UART_H_
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
# uniq is a function which remove duplicate elements from a list
uniq = $(strip $(if $1,$(firstword $1) \
$(call uniq,$(filter-out $(firstword $1),$1))))
DEVICE = EFM32GG330F1024
PROJECTNAME = usbdcdc
OOCD_IFACE ?= stlink-v2-1
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.8 2013q4
LINUXCS ?= /opt/gcc-arm-none-eabi-4_8-2014q1
RMDIRS := rm -rf
RMFILES := rm -rf
ALLFILES := /*.*
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RMDIRS := rd /s /q
RMFILES := del /s /q
ALLFILES := \*.*
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RMFILES) $(OBJ_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(EXE_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(LST_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
SIZE = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-size$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb \
-mfix-cortex-m3-ldrd -ffunction-sections \
-fdata-sections -fomit-frame-pointer -DDEBUG_EFM_USER \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -DDEBUG_EFM_USER
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../../common/Device/EnergyMicro/EFM32GG/Source/GCC/efm32gg.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I../src \
-I../src \
-I../../common/CMSIS/Include \
-I../../common/Device/EnergyMicro/EFM32GG/Include \
-I../../common/emlib/inc \
-I../usb/inc \
-I../kits/common/drivers \
-I../kits/common/bsp \
-I../kits/EFM32GG_DK3750/config
####################################################################
# Files #
####################################################################
C_SRC += \
../../common/Device/EnergyMicro/EFM32GG/Source/system_efm32gg.c \
../../common/emlib/src/em_assert.c \
../../common/emlib/src/em_cmu.c \
../../common/emlib/src/em_dma.c \
../../common/emlib/src/em_ebi.c \
../../common/emlib/src/em_emu.c \
../../common/emlib/src/em_gpio.c \
../../common/emlib/src/em_int.c \
../../common/emlib/src/em_system.c \
../../common/emlib/src/em_timer.c \
../../common/emlib/src/em_leuart.c \
../usb/src/em_usbd.c \
../usb/src/em_usbdch9.c \
../usb/src/em_usbhal.c \
../usb/src/em_usbdep.c \
../usb/src/em_usbdint.c \
../usb/src/em_usbtimer.c \
../kits/common/drivers/dmactrl.c \
../src/main.c
s_SRC +=
S_SRC += \
../../common/Device/EnergyMicro/EFM32GG/Source/GCC/startup_efm32gg.S
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, uniq removes duplicate paths
C_PATHS = $(call uniq, $(dir $(C_SRC) ) )
S_PATHS = $(call uniq, $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
$(SIZE) $<
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RMDIRS) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
flash: $(EXE_DIR)/$(PROJECTNAME).bin
openocd -s ../../common/openocd -f interface/$(OOCD_IFACE).cfg -f init.cfg -c "program $(EXE_DIR)/$(PROJECTNAME).bin 0 verify reset"
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
####################################################################
# Makefile #
####################################################################
.SUFFIXES: # ignore builtin rules
.PHONY: all debug release clean
####################################################################
# Definitions #
####################################################################
# uniq is a function which remove duplicate elements from a list
uniq = $(strip $(if $1,$(firstword $1) \
$(call uniq,$(filter-out $(firstword $1),$1))))
DEVICE = EFM32GG990F1024
PROJECTNAME = usbdcdc
OBJ_DIR = build
EXE_DIR = exe
LST_DIR = lst
####################################################################
# Definitions of toolchain. #
# You might need to do changes to match your system setup #
####################################################################
# Change path to the tools according to your system configuration
# DO NOT add trailing whitespace chars, they do matter !
WINDOWSCS ?= GNU Tools ARM Embedded\4.8 2013q4
LINUXCS ?= /cad/arm-embedded/gcc-arm-none-eabi-4_7-2012q4
RMDIRS := rm -rf
RMFILES := rm -rf
ALLFILES := /*.*
NULLDEVICE := /dev/null
SHELLNAMES := $(ComSpec)$(COMSPEC)
# Try autodetecting the environment
ifeq ($(SHELLNAMES),)
# Assume we are making on a Linux platform
TOOLDIR := $(LINUXCS)
else
QUOTE :="
ifneq ($(COMSPEC),)
# Assume we are making on a mingw/msys/cygwin platform running on Windows
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
TOOLDIR := $(PROGRAMFILES)/$(WINDOWSCS)
ifeq ($(findstring cygdrive,$(shell set)),)
# We were not on a cygwin platform
NULLDEVICE := NUL
endif
else
# Assume we are making on a Windows platform
# This is a convenient place to override TOOLDIR, DO NOT add trailing
# whitespace chars, they do matter !
SHELL := $(SHELLNAMES)
TOOLDIR := $(ProgramFiles)/$(WINDOWSCS)
RMDIRS := rd /s /q
RMFILES := del /s /q
ALLFILES := \*.*
NULLDEVICE := NUL
endif
endif
# Create directories and do a clean which is compatible with parallell make
$(shell mkdir $(OBJ_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(EXE_DIR)>$(NULLDEVICE) 2>&1)
$(shell mkdir $(LST_DIR)>$(NULLDEVICE) 2>&1)
ifeq (clean,$(findstring clean, $(MAKECMDGOALS)))
ifneq ($(filter $(MAKECMDGOALS),all debug release),)
$(shell $(RMFILES) $(OBJ_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(EXE_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
$(shell $(RMFILES) $(LST_DIR)$(ALLFILES)>$(NULLDEVICE) 2>&1)
endif
endif
CC = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-gcc$(QUOTE)
LD = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ld$(QUOTE)
AR = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-ar$(QUOTE)
OBJCOPY = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objcopy$(QUOTE)
DUMP = $(QUOTE)$(TOOLDIR)/bin/arm-none-eabi-objdump$(QUOTE)
####################################################################
# Flags #
####################################################################
# -MMD : Don't generate dependencies on system header files.
# -MP : Add phony targets, useful when a h-file is removed from a project.
# -MF : Specify a file to write the dependencies to.
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
#
# Add -Wa,-ahld=$(LST_DIR)/$(@F:.o=.lst) to CFLAGS to produce assembly list files
#
override CFLAGS += -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb \
-mfix-cortex-m3-ldrd -ffunction-sections \
-fdata-sections -fomit-frame-pointer -DDEBUG_EFM_USER \
$(DEPFLAGS)
override ASMFLAGS += -x assembler-with-cpp -D$(DEVICE) -Wall -Wextra -mcpu=cortex-m3 -mthumb -DDEBUG_EFM_USER
#
# NOTE: The -Wl,--gc-sections flag may interfere with debugging using gdb.
#
override LDFLAGS += -Xlinker -Map=$(LST_DIR)/$(PROJECTNAME).map -mcpu=cortex-m3 \
-mthumb -T../Device/SiliconLabs/EFM32GG/Source/GCC/efm32gg.ld \
-Wl,--gc-sections
LIBS = -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
INCLUDEPATHS += \
-I../src \
-I../src \
-I../CMSIS/Include \
-I../Device/SiliconLabs/EFM32GG/Include \
-I../emlib/inc \
-I../usb/inc \
-I../kits/common/drivers \
-I../kits/common/bsp \
-I../kits/EFM32GG_DK3750/config
####################################################################
# Files #
####################################################################
C_SRC += \
../Device/SiliconLabs/EFM32GG/Source/system_efm32gg.c \
../kits/common/bsp/bsp_dk_3201.c \
../kits/common/bsp/bsp_trace.c \
../kits/common/drivers/dmactrl.c \
../emlib/src/em_assert.c \
../emlib/src/em_cmu.c \
../emlib/src/em_dma.c \
../emlib/src/em_ebi.c \
../emlib/src/em_emu.c \
../emlib/src/em_gpio.c \
../emlib/src/em_int.c \
../emlib/src/em_system.c \
../emlib/src/em_timer.c \
../emlib/src/em_usart.c \
../usb/src/em_usbd.c \
../usb/src/em_usbdch9.c \
../usb/src/em_usbhal.c \
../usb/src/em_usbdep.c \
../usb/src/em_usbdint.c \
../usb/src/em_usbtimer.c \
../src/main.c
s_SRC +=
S_SRC += \
../Device/SiliconLabs/EFM32GG/Source/GCC/startup_efm32gg.S
####################################################################
# Rules #
####################################################################
C_FILES = $(notdir $(C_SRC) )
S_FILES = $(notdir $(S_SRC) $(s_SRC) )
#make list of source paths, uniq removes duplicate paths
C_PATHS = $(call uniq, $(dir $(C_SRC) ) )
S_PATHS = $(call uniq, $(dir $(S_SRC) $(s_SRC) ) )
C_OBJS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.o))
S_OBJS = $(if $(S_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.S=.o)))
s_OBJS = $(if $(s_SRC), $(addprefix $(OBJ_DIR)/, $(S_FILES:.s=.o)))
C_DEPS = $(addprefix $(OBJ_DIR)/, $(C_FILES:.c=.d))
OBJS = $(C_OBJS) $(S_OBJS) $(s_OBJS)
vpath %.c $(C_PATHS)
vpath %.s $(S_PATHS)
vpath %.S $(S_PATHS)
# Default build is debug build
all: debug
debug: CFLAGS += -DDEBUG -O0 -g
debug: $(EXE_DIR)/$(PROJECTNAME).bin
release: CFLAGS += -DNDEBUG -O0 -g
release: $(EXE_DIR)/$(PROJECTNAME).bin
# Create objects from C SRC files
$(OBJ_DIR)/%.o: %.c
@echo "Building file: $<"
$(CC) $(CFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Assemble .s/.S files
$(OBJ_DIR)/%.o: %.s
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
$(OBJ_DIR)/%.o: %.S
@echo "Assembling $<"
$(CC) $(ASMFLAGS) $(INCLUDEPATHS) -c -o $@ $<
# Link
$(EXE_DIR)/$(PROJECTNAME).out: $(OBJS)
@echo "Linking target: $@"
$(CC) $(LDFLAGS) $(OBJS) $(LIBS) -o $(EXE_DIR)/$(PROJECTNAME).out
# Create binary file
$(EXE_DIR)/$(PROJECTNAME).bin: $(EXE_DIR)/$(PROJECTNAME).out
@echo "Creating binary file"
$(OBJCOPY) -O binary $(EXE_DIR)/$(PROJECTNAME).out $(EXE_DIR)/$(PROJECTNAME).bin
# Uncomment next line to produce assembly listing of entire program
# $(DUMP) -h -S -C $(EXE_DIR)/$(PROJECTNAME).out>$(LST_DIR)/$(PROJECTNAME)out.lst
clean:
ifeq ($(filter $(MAKECMDGOALS),all debug release),)
$(RMDIRS) $(OBJ_DIR) $(LST_DIR) $(EXE_DIR)
endif
# include auto-generated dependency files (explicit rules)
ifneq (clean,$(findstring clean, $(MAKECMDGOALS)))
-include $(C_DEPS)
endif
/***************************************************************************//**
* @file
* @brief Provide BSP (board support package) configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSPCONFIG_H
#define __BSPCONFIG_H
#define BSP_DK
#define BSP_DK_3201
#define BSP_MCUBOARD_3600
#define BSP_MCUBOARD_USB
#define BSP_USB_STATUSLED_PORT gpioPortE
#define BSP_USB_STATUSLED_PIN 1
#define BSP_USB_OCFLAG_PORT gpioPortE
#define BSP_USB_OCFLAG_PIN 2
#define BSP_USB_VBUSEN_PORT gpioPortF
#define BSP_USB_VBUSEN_PIN 5
#include "bsp_dk_bcreg_3201.h"
#define BSP_DK_LEDS
#define BSP_NO_OF_LEDS 16
#define BSP_LED_MASK 0xFFFF
#define BSP_LED_PORT (&BC_REGISTER->UIF_LEDS)
#define BSP_INIT_DEFAULT BSP_INIT_DK_EBI
#endif
/***************************************************************************//**
* @file
* @brief Provide I2CDRV configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __I2CDRVCONFIG_H
#define __I2CDRVCONFIG_H
/// I2C pin/port configuration. Note that this driver supports only one
/// driver instance.
#define I2CDRV_PORT_LOCATION 3 /// Location used on DK
#define I2CDRV_SCL_PORT gpioPortD
#define I2CDRV_SCL_PIN 15
#define I2CDRV_SDA_PORT gpioPortD
#define I2CDRV_SDA_PIN 14
#define I2CDRV_TRANSFER_TIMEOUT 300000
#endif
/***************************************************************************//**
* @file
* @brief Provide MicroSD SPI configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __MICROSDCONFIG_H
#define __MICROSDCONFIG_H
/* Don't increase MICROSD_HI_SPI_FREQ beyond 12MHz. Next step will be 24MHz */
/* which is out of spec. */
#define MICROSD_HI_SPI_FREQ 12000000
#define MICROSD_LO_SPI_FREQ 100000
#define MICROSD_USART USART0
#define MICROSD_LOC USART_ROUTE_LOCATION_LOC1
#define MICROSD_CMUCLOCK cmuClock_USART0
#define MICROSD_GPIOPORT gpioPortE
#define MICROSD_MOSIPIN 7
#define MICROSD_MISOPIN 6
#define MICROSD_CSPIN 4
#define MICROSD_CLKPIN 5
#endif /* __MICROSDCONFIG_H */
/***************************************************************************//**
* @file
* @brief Provide stdio retargeting configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __RETARGETSERIALCONFIG_H
#define __RETARGETSERIALCONFIG_H
#include "bsp.h"
/* Override if needed with commandline parameter -DRETARGET_xxx */
#if !defined(RETARGET_UART1) && !defined(RETARGET_LEUART1)
#define RETARGET_UART1 /* Use UART1 by default. */
#endif
#if defined(RETARGET_UART1)
#define RETARGET_IRQ_NAME UART1_RX_IRQHandler /* UART IRQ Handler */
#define RETARGET_CLK cmuClock_UART1 /* HFPER Clock */
#define RETARGET_IRQn UART1_RX_IRQn /* IRQ number */
#define RETARGET_UART UART1 /* UART instance */
#define RETARGET_TX USART_Tx /* Set TX to USART_Tx */
#define RETARGET_RX USART_Rx /* Set RX to USART_Rx */
#define RETARGET_LOCATION USART_ROUTE_LOCATION_LOC2 /* Location of of the USART I/O pins */
#define RETARGET_TXPORT gpioPortB /* UART transmission port */
#define RETARGET_TXPIN 9 /* UART transmission pin */
#define RETARGET_RXPORT gpioPortB /* UART reception port */
#define RETARGET_RXPIN 10 /* UART reception pin */
#define RETARGET_USART 1 /* Includes em_usart.h */
#define RETARGET_PERIPHERAL_ENABLE() BSP_PeripheralAccess(BSP_RS232_UART, true)
#elif defined(RETARGET_LEUART1)
#define RETARGET_IRQ_NAME LEUART1_IRQHandler /* LEUART IRQ Handler */
#define RETARGET_CLK cmuClock_LEUART1 /* LFB Clock */
#define RETARGET_IRQn LEUART1_IRQn /* IRQ number */
#define RETARGET_UART LEUART1 /* LEUART instance */
#define RETARGET_TX LEUART_Tx /* Set TX to LEUART_Tx */
#define RETARGET_RX LEUART_Rx /* Set RX to LEUART_Rx */
#define RETARGET_TXPORT gpioPortC /* LEUART transmission port */
#define RETARGET_TXPIN 6 /* LEUART transmission pin */
#define RETARGET_RXPORT gpioPortC /* LEUART reception port */
#define RETARGET_RXPIN 7 /* LEUART reception pin */
#define RETARGET_LOCATION LEUART_ROUTE_LOCATION_LOC0 /* Location of of the LEUART I/O pins */
#define RETARGET_LEUART 1 /* Includes em_leuart.h */
#define RETARGET_PERIPHERAL_ENABLE() BSP_PeripheralAccess(BSP_RS232_LEUART, true)
#else
#error "Illegal UART/LEUART selection."
#endif
#endif
/***************************************************************************//**
* @file
* @brief Provide SWO/ETM TRACE configuration parameters.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __TRACECONFIG_H
#define __TRACECONFIG_H
#define BSP_TRACE_SWO_LOCATION GPIO_ROUTE_SWLOCATION_LOC0
/* Enable output on pin - GPIO Port F, Pin 2. */
#define TRACE_ENABLE_PINS() \
GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK); \
GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL
#define BSP_ETM_TRACE /* This DK supports ETM trace. */
#endif
/***************************************************************************//**
* @file
* @brief Board support package API definitions.
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_H
#define __BSP_H
#include <stdbool.h>
#include "bspconfig.h"
#if defined( BSP_STK )
#include "em_usart.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup BSPCOMMON API common for all kits */ /** @{ */
#define BSP_STATUS_OK 0 /**< BSP API return code, no errors. */
#define BSP_STATUS_ILLEGAL_PARAM (-1) /**< BSP API return code, illegal input parameter. */
#define BSP_STATUS_NOT_IMPLEMENTED (-2) /**< BSP API return code, function not implemented (dummy). */
#define BSP_STATUS_UNSUPPORTED_MODE (-3) /**< BSP API return code, unsupported BSP mode. */
/* Initialization flag bitmasks for BSP_Init(). */
#define BSP_INIT_DK_SPI 0x01 /**< Mode flag for @ref BSP_Init(), init DK in SPI mode (DK3x50 only). */
#define BSP_INIT_DK_EBI 0x02 /**< Mode flag for @ref BSP_Init(), init DK in EBI mode (DK3x50 only). */
#define BSP_INIT_BCC 0x04 /**< Mode flag for @ref BSP_Init(), init board controller communication. */
/** @} */
#if defined( BSP_DK )
/** @addtogroup BSP_DK API for DK's */ /** @{ */
/** Display Control */
typedef enum
{
BSP_Display_EBI, /**< SSD2119 TFT controller driven by EFM32 EBI interface */
BSP_Display_SPI, /**< SSD2119 TFT controller driven by EFM32 SPI interface */
BSP_Display_BC, /**< SSD2119 TFT controller driven by board controller (AEM) */
BSP_Display_PowerEnable, /**< SSD2119 Enable power */
BSP_Display_PowerDisable, /**< SSD2119 Disable power */
BSP_Display_ResetAssert, /**< Hold SSD2119 in reset */
BSP_Display_ResetRelease, /**< Release SSD2119 in reset */
BSP_Display_Mode8080, /**< Configure SSD2119 for 8080 mode of operation */
BSP_Display_ModeGeneric, /**< Configure SSD2119 for Generic+SPI mode of operation */
} BSP_Display_TypeDef;
/** Bus control access mode */
typedef enum
{
BSP_BusControl_Undefined=0, /**< Board control mode unknown (not set) */
BSP_BusControl_OFF, /**< Board control disable */
BSP_BusControl_DIRECT, /**< GPIO direct drive (n/a) */
BSP_BusControl_SPI, /**< Configure Board controller for SPI mode */
BSP_BusControl_EBI, /**< Configure Board controller for EBI mode */
} BSP_BusControl_TypeDef;
#if defined( BSP_DK_3200 ) /* Gxxx_DK */
/** Peripherals control structure for Gxxx_DK's. */
typedef enum
{
BSP_ACCEL = BC_PERCTRL_ACCEL, /**< Accelerometer */
BSP_AMBIENT = BC_PERCTRL_AMBIENT, /**< Light sensor */
BSP_POTMETER = BC_PERCTRL_POTMETER, /**< Potentiometer */
BSP_RS232A = BC_PERCTRL_RS232A, /**< Serial port A */
BSP_RS232B = BC_PERCTRL_RS232B, /**< Serial port B */
BSP_SPI = BC_PERCTRL_SPI, /**< SPI interface */
BSP_I2C = BC_PERCTRL_I2C, /**< I2C interface */
BSP_IRDA = BC_PERCTRL_IRDA, /**< IrDA interface */
BSP_ANALOG_SE = BC_PERCTRL_ANALOG_SE, /**< Single ended analog input */
BSP_ANALOG_DIFF = BC_PERCTRL_ANALOG_DIFF, /**< Differential analog input */
BSP_AUDIO_OUT = BC_PERCTRL_AUDIO_OUT, /**< Audio Out */
BSP_AUDIO_IN = BC_PERCTRL_AUDIO_IN, /**< Audio In */
BSP_ACCEL_GSEL = BC_PERCTRL_ACCEL_GSEL, /**< Accelerometer range select */
BSP_ACCEL_SELFTEST = BC_PERCTRL_ACCEL_SELFTEST, /**< Accelerometer selftest mode */
BSP_RS232_SHUTDOWN = BC_PERCTRL_RS232_SHUTDOWN, /**< Disable RS232 */
BSP_IRDA_SHUTDOWN = BC_PERCTRL_IRDA_SHUTDOWN /**< Disable IrDA */
#ifdef DOXY_DOC_ONLY
} BSP_Peripheral_Typedef; /* Hack for doxygen doc ! */
#else
} BSP_Peripheral_TypeDef;
#endif
#endif /* BSP_DK_3200 */
#if defined( BSP_DK_3201 ) /* DK3x50 DK's */
/** Peripherals control structure for DK3x50 DK's. */
typedef enum
{
BSP_RS232_SHUTDOWN, /**< Disable RS232 */
BSP_RS232_UART, /**< UART control of RS232 */
BSP_RS232_LEUART, /**< LEUART control of RS232 */
BSP_I2C, /**< I2C interface */
BSP_ETH, /**< Ethernet */
BSP_I2S, /**< Audio I2S */
BSP_TRACE, /**< ETM Trace */
BSP_TOUCH, /**< Display touch interface */
BSP_AUDIO_IN, /**< Audio In */
BSP_AUDIO_OUT, /**< Audio Out */
BSP_ANALOG_DIFF, /**< Differential analog input */
BSP_ANALOG_SE, /**< Single ended analog input */
BSP_MICROSD, /**< MicroSD SPI interace */
BSP_TFT, /**< SSD2119 TFT controller */
} BSP_Peripheral_TypeDef;
#endif /* BSP_DK_3201 */
/** @} */
#endif /* BSP_DK */
/************************** The BSP API *******************************/
int BSP_Disable ( void );
int BSP_Init ( uint32_t flags );
int BSP_LedClear ( int ledNo );
int BSP_LedGet ( int ledNo );
int BSP_LedSet ( int ledNo );
uint32_t BSP_LedsGet ( void );
int BSP_LedsInit ( void );
int BSP_LedsSet ( uint32_t leds );
int BSP_LedToggle ( int ledNo );
#if defined( BSP_DK )
BSP_BusControl_TypeDef BSP_BusControlModeGet( void );
int BSP_BusControlModeSet ( BSP_BusControl_TypeDef mode );
uint32_t BSP_DipSwitchGet ( void );
int BSP_DisplayControl ( BSP_Display_TypeDef option );
int BSP_EbiExtendedAddressRange ( bool enable );
int BSP_EnergyModeSet ( uint16_t energyMode );
int BSP_InterruptDisable ( uint16_t flags );
int BSP_InterruptEnable ( uint16_t flags );
int BSP_InterruptFlagsClear ( uint16_t flags );
int BSP_InterruptFlagsSet ( uint16_t flags );
uint16_t BSP_InterruptFlagsGet ( void );
uint16_t BSP_JoystickGet ( void );
int BSP_McuBoard_DeInit ( void );
int BSP_McuBoard_Init ( void );
int BSP_McuBoard_UsbStatusLedEnable ( bool enable );
bool BSP_McuBoard_UsbVbusOcFlagGet ( void );
int BSP_McuBoard_UsbVbusPowerEnable ( bool enable );
int BSP_PeripheralAccess ( BSP_Peripheral_TypeDef perf, bool enable );
uint16_t BSP_PushButtonsGet ( void );
uint16_t BSP_RegisterRead ( volatile uint16_t *addr );
int BSP_RegisterWrite ( volatile uint16_t *addr, uint16_t data );
#endif
#if defined( BSP_STK )
int BSP_BccDeInit ( void );
int BSP_BccInit ( void );
bool BSP_BccPacketReceive ( BCP_Packet *pkt );
int BSP_BccPacketSend ( BCP_Packet *pkt );
void BSP_BccPinsEnable ( bool enable );
float BSP_CurrentGet ( void );
int BSP_EbiDeInit ( void );
int BSP_EbiInit ( void );
float BSP_VoltageGet ( void );
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BSP_H */
/***************************************************************************//**
* @file
* @brief Board Controller Communications (BCC) definitions
* @version 3.20.5
*******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#include <string.h>
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "bsp.h"
#if defined( BSP_BCC_LEUART )
#include "em_leuart.h"
#else
#include "em_usart.h"
#endif
#if defined( BSP_STK )
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/* Module local variables */
static uint32_t rxByteCount;
static uint32_t txByteCount;
/* Module local prototypes */
static void TxByte( uint8_t data );
static uint8_t RxByte( void );
/** @endcond */
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSP_STK API for STK's
* @{
******************************************************************************/
/**************************************************************************//**
* @brief Deinitialize board controller communication support (BCC)
* functionality. Reverse actions performed by @ref BSP_BccInit().
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccDeInit( void )
{
/* Reset counters */
rxByteCount = 0xFFFFFFFFUL;
txByteCount = 0xFFFFFFFFUL;
BSP_BccPinsEnable( false );
#if defined( BSP_BCC_LEUART )
/* Reset LEUART */
LEUART_Reset( BSP_BCC_LEUART );
#else
/* Reset USART */
USART_Reset( BSP_BCC_USART );
#endif
/* Disable clock */
CMU_ClockEnable( BSP_BCC_CLK, false );
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Initialize board controller communication support (BCC)
* functionality.
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccInit( void )
{
#if defined( BSP_BCC_LEUART )
LEUART_Init_TypeDef leuartInit = LEUART_INIT_DEFAULT;
#else
USART_InitAsync_TypeDef usartInit = USART_INITASYNC_DEFAULT;
#endif
rxByteCount = 0;
txByteCount = 0;
/* Enable High Frequency Peripherals */
CMU_ClockEnable(cmuClock_HFPER, true);
/* Enable clocks to GPIO */
CMU_ClockEnable(cmuClock_GPIO, true);
/* Enable UART clock */
CMU_ClockEnable( BSP_BCC_CLK, true );
#if defined( BSP_BCC_LEUART )
/* Enable CORE LE clock in order to access LE modules */
CMU_ClockEnable(cmuClock_CORELE, true);
/* Select CORE LE clock for LE modules */
CMU_ClockSelectSet( cmuClock_LFB, cmuSelect_CORELEDIV2 );
/* Initialize LEUART */
leuartInit.baudrate = 115200;
LEUART_Init( BSP_BCC_LEUART, &leuartInit );
#else
/* Initialize USART */
USART_InitAsync( BSP_BCC_USART, &usartInit );
#endif
/* Initialize UART pins */
BSP_BccPinsEnable( true );
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Get a packet from the board controller.
*
* @param[in] pkt Pointer to a @ref BCP_Packet instance.
*
* @return True if packet received without errors, false otherwise.
*****************************************************************************/
bool BSP_BccPacketReceive( BCP_Packet *pkt )
{
int i;
int length;
uint8_t *bptr;
/* Setup a byte pointer to start of packet buffer */
bptr = (uint8_t *) pkt;
/* Receive packet magic */
*bptr++ = RxByte();
if (pkt->magic != BSP_BCP_MAGIC)
{
return false;
}
/* Receive packet type */
*bptr++ = RxByte();
if ( (pkt->type < BSP_BCP_FIRST) || (pkt->type > BSP_BCP_LAST) )
{
return false;
}
/* Receive packet length */
*bptr++ = RxByte();
if (pkt->payloadLength > BSP_BCP_PACKET_SIZE)
{
return false;
}
#if ( BSP_BCP_VERSION == 2 )
/* Receive reserved byte */
*bptr++ = RxByte();
#endif
/* Receive packet data length field and sanity check it */
length = pkt->payloadLength;
if (length > BSP_BCP_PACKET_SIZE)
{
length = BSP_BCP_PACKET_SIZE;
}
/* Receive packet payload */
for( i=0; i<length; i++ )
{
*bptr++ = RxByte();
}
return true;
}
/**************************************************************************//**
* @brief Send a packet to the board controller.
*
* @param[in] pkt Pointer to a @ref BCP_Packet instance.
*
* @return @ref BSP_STATUS_OK.
*****************************************************************************/
int BSP_BccPacketSend( BCP_Packet *pkt )
{
int i;
/* Apply magic */
pkt->magic = BSP_BCP_MAGIC;
/* Transmit packet magic */
TxByte( pkt->magic );
/* Transmit packet type */
TxByte( pkt->type );
/* Transmit packet length */
TxByte( pkt->payloadLength );
#if ( BSP_BCP_VERSION == 2 )
/* Transmit reserved byte */
TxByte( pkt->reserved );
#endif
/* Transmit packet payload */
for ( i=0; i<pkt->payloadLength; i++ )
{
TxByte( pkt->data[i] );
}
return BSP_STATUS_OK;
}
/**************************************************************************//**
* @brief Enable GPIO pins for the USART/LEUART used for board communication.
*
* @param[in] enable Set to true to enable pins, set to false to disable.
*****************************************************************************/
void BSP_BccPinsEnable( bool enable )
{
if (enable)
{
/* Configure GPIO pin for UART TX */
/* To avoid false start, configure output as high. */
GPIO_PinModeSet( BSP_BCC_TXPORT, BSP_BCC_TXPIN, gpioModePushPull, 1 );
/* Configure GPIO pin for UART RX */
GPIO_PinModeSet( BSP_BCC_RXPORT, BSP_BCC_RXPIN, gpioModeInput, 1 );
/* Enable the switch that enables UART communication. */
GPIO_PinModeSet( BSP_BCC_ENABLE_PORT, BSP_BCC_ENABLE_PIN, gpioModePushPull, 1 );
#if defined( BSP_BCC_LEUART )
BSP_BCC_LEUART->ROUTE |= LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN | BSP_BCC_LOCATION;
#else
BSP_BCC_USART->ROUTE |= USART_ROUTE_RXPEN | USART_ROUTE_TXPEN | BSP_BCC_LOCATION;
#endif
}
else
{
GPIO_PinModeSet( BSP_BCC_ENABLE_PORT, BSP_BCC_ENABLE_PIN, gpioModeDisabled, 0 );
#if defined( BSP_BCC_LEUART )
BSP_BCC_LEUART->ROUTE &= ~(LEUART_ROUTE_RXPEN | LEUART_ROUTE_TXPEN);
#else
BSP_BCC_USART->ROUTE &= ~(USART_ROUTE_RXPEN | USART_ROUTE_TXPEN);
#endif
GPIO_PinModeSet( BSP_BCC_TXPORT, BSP_BCC_TXPIN, gpioModeDisabled, 0 );
GPIO_PinModeSet( BSP_BCC_RXPORT, BSP_BCC_RXPIN, gpioModeDisabled, 0 );
}
}
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
static uint8_t RxByte( void )
{
uint8_t byte;
/* Poll RX data available flag and return a character when one is available */
#if defined( BSP_BCC_LEUART )
while (!(BSP_BCC_LEUART->IF & LEUART_IF_RXDATAV)) ;
byte = BSP_BCC_LEUART->RXDATA;
#else
while (!(BSP_BCC_USART->STATUS & USART_STATUS_RXDATAV)) ;
byte = BSP_BCC_USART->RXDATA;
#endif
rxByteCount++;
return byte;
}
static void TxByte( uint8_t data )
{
/* Check TX buffer and allow for a pending transfer to complete */
#if defined( BSP_BCC_LEUART )
while (!(BSP_BCC_LEUART->STATUS & LEUART_STATUS_TXBL)) ;
BSP_BCC_LEUART->TXDATA = (uint32_t) data;
#else
while (!(BSP_BCC_USART->STATUS & USART_STATUS_TXBL)) ;
BSP_BCC_USART->TXDATA = (uint32_t) data;
#endif
txByteCount++;
}
/** @endcond */
/** @} (end group BSP_STK) */
/** @} (end group BSP) */
#endif /* BSP_STK */
/**************************************************************************//**
* @file
* @brief Board Controller Communications Protocol (BCP) definitions
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_BCP_H
#define __BSP_BCP_H
#include <stdint.h>
#include "bspconfig.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup BSP_STK API for STK's
* @{
******************************************************************************/
/* BCP Packet Types */
#define BSP_BCP_INVALID 0 /**< Invalid packet received */
#define BSP_BCP_FIRST 1 /**< Smallest numerical value of message type */
#define BSP_BCP_ACK 5 /**< Generic ACK for one way packages */
#define BSP_BCP_ECHO_REQ 10 /**< EFM32 BC alive request */
#define BSP_BCP_ECHO_REPLY 11 /**< BC alive response */
#define BSP_BCP_CURRENT_REQ 14 /**< EFM32 Request AEM current */
#define BSP_BCP_CURRENT_REPLY 16 /**< BC Response AEM current */
#define BSP_BCP_VOLTAGE_REQ 18 /**< EFM32 Request AEM voltage */
#define BSP_BCP_VOLTAGE_REPLY 20 /**< BC Response AEM voltage */
#define BSP_BCP_ENERGYMODE 22 /**< EFM32 Report Energy Mode (for AEM) */
#define BSP_BCP_STDOUT 24 /**< Debug packet (not used) */
#define BSP_BCP_STDERR 26 /**< Debug packet (not used) */
#define BSP_BCP_TEST 32 /**< Reserved type for test */
#define BSP_BCP_TEST_REPLY 33 /**< Reserved type for test (reply) */
#define BSP_BCP_NET_REQUEST 64 /**< Net gateway request packet */
#define BSP_BCP_NET_REPLY 65 /**< Net gateway reply packet */
#define BSP_BCP_LAST 100 /**< Last defined message type */
#define BSP_BCP_MAGIC 0xF1 /**< Magic byte to indicate start of packet */
#if ( ( BSP_BCP_VERSION == 1 ) || DOXY_DOC_ONLY )
#ifdef DOXY_DOC_ONLY
/* Hack for doxygen doc ! */
#define BSP_BCP_PACKET_SIZe 30 /**< Max packet size for version 1 of the protocol. */
#else
#define BSP_BCP_PACKET_SIZE 30 /**< Max packet size for version 1 of the protocol. */
#endif
/** @brief BCP Packet Structure - Board controller communication protocol version 1. */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type of packet */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t data[BSP_BCP_PACKET_SIZE]; /**< BCP Packet Data payload */
#ifdef DOXY_DOC_ONLY
} BCP_Packet_; /* Hack for doxygen doc ! */
#else
} BCP_Packet;
#endif
#endif
#if ( ( BSP_BCP_VERSION == 2 ) || DOXY_DOC_ONLY )
#define BSP_BCP_PACKET_SIZE 132 /**< Max packet size for version 2 of the protocol. */
/** @brief BCP Packet Structure - Board controller communication protocol version 2. */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type - packet type */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t reserved; /**< Reserved for future expansion */
uint8_t data[BSP_BCP_PACKET_SIZE]; /**< BCP Packet Data payload */
} BCP_Packet;
/** @brief BCP Packet Header definition */
typedef struct
{
uint8_t magic; /**< Magic - start of packet - must be BSP_BCP_MAGIC */
uint8_t type; /**< Type - packet type */
uint8_t payloadLength; /**< Length of data segment >=0 and <=BSP_BCP_PACKET_SIZE */
uint8_t reserved; /**< Reserved for future expansion */
} BCP_PacketHeader;
#endif
#if ( ( BSP_BCP_VERSION != 1 ) && ( BSP_BCP_VERSION != 2 ) )
#error "BSP BCP Board Controller communications protocol version error."
#endif
#if ( BSP_BCP_PACKET_SIZE >= 255 )
#error "BSP BCP Board Controller communications packets must be less than 255 bytes in size!"
#endif
/** @} (end group BSP_STK) */
#ifdef __cplusplus
}
#endif
#endif /* __BSP_BCP_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**************************************************************************//**
* @file
* @brief SWO Trace API (for eAProfiler)
* @version 3.20.5
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __BSP_TRACE_H
#define __BSP_TRACE_H
#include "em_device.h"
#if (defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )) || defined( GPIO_ROUTE_SWOPEN )
#include <stdint.h>
#include <stdbool.h>
#include "em_msc.h"
#include "traceconfig.h"
/***************************************************************************//**
* @addtogroup BSP
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup BSPCOMMON API common for all kits
* @{
******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )
void BSP_TraceEtmSetup(void);
#endif
#if defined( GPIO_ROUTE_SWOPEN )
bool BSP_TraceProfilerSetup(void);
void BSP_TraceSwoSetup(void);
#endif
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
#define USER_PAGE 0x0FE00000UL /* Address to flash memory */
/** @endcond */
/**************************************************************************//**
* @brief Set or clear word in user page which enables or disables SWO
* in BSP_TraceProfilerSetup. If BSP_TraceProfilerEnable(false) has been run,
* no example project will enable SWO trace.
* @param[in] enable
* @note Add "em_msc.c" to build to use this function.
*****************************************************************************/
__STATIC_INLINE void BSP_TraceProfilerEnable(bool enable)
{
uint32_t data;
volatile uint32_t *userpage = (uint32_t *) USER_PAGE;
/* Check that configuration needs to change */
data = *userpage;
if (enable)
{
if (data == 0xFFFFFFFF)
{
return;
}
}
else
{
if (data == 0x00000000)
{
return;
}
}
/* Initialize MSC */
MSC_Init();
/* Write enable or disable trigger word into flash */
if (enable)
{
data = 0xFFFFFFFF;
MSC_ErasePage((uint32_t *) USER_PAGE);
MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
}
else
{
data = 0x00000000;
MSC_ErasePage((uint32_t *) USER_PAGE);
MSC_WriteWord((uint32_t *) USER_PAGE, (void *) &data, 4);
}
}
#ifdef __cplusplus
}
#endif
/** @} (end group BSP) */
/** @} (end group BSP) */
#endif /* (defined(BSP_ETM_TRACE) && defined( ETM_PRESENT )) || defined( GPIO_ROUTE_SWOPEN ) */
#endif /* __BSP_TRACE_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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