Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d31730c
Serial1/2 dynamic re-code working. Transmit test OK on both ports. Wi…
gruvin Apr 23, 2014
04d2fea
Merge branch 'feature/serial2' of https://github.com/gruvin/core-firm…
gruvin Apr 23, 2014
0d04551
A little tidying of USART_MAP
gruvin Apr 23, 2014
b1054a8
Tidied up some lazily-unneeded pointers. Created _UMAP macro to impro…
gruvin Apr 23, 2014
40e424b
Ammend/completed USART_MAP doc comments
gruvin Apr 23, 2014
59663d8
Serial receive tested OK.
gruvin Apr 24, 2014
f8d65df
Tidied up interrupt handler pointers. (This resulted in 8 _more_ byte…
gruvin Apr 24, 2014
673ece0
Trivial: removed ambuigous,'Spark_' from USART_Interrupt_Handler(...)
gruvin Apr 24, 2014
5c656c3
Edited README.md to explain purpose and method of this branch.
gruvin Apr 24, 2014
9ff525b
Fixed some README typos and gramma
gruvin Apr 24, 2014
6c65835
Removed test code from application.cpp.
gruvin Apr 24, 2014
b4478a3
Added Flash binary size increase anaylsis from adding Serial2 support…
gruvin Apr 24, 2014
a5c8f46
Corrects(?) to code size cost anaylis, README.md.
gruvin Apr 24, 2014
5cca228
Removed unintended, temp file in build dir.
gruvin Apr 24, 2014
c795cd2
Created new libraries folder and moved Serial2 instantiation to libra…
gruvin May 28, 2014
e46e3f1
Final feature/serial2 implementation (for now) including libraries/Se…
gruvin May 28, 2014
5ddb2f4
Added comment about need for ISR helper function being shared and nee…
gruvin May 28, 2014
6f19d33
Oops. Forgot to remove the `#include "Serial2.h"` bit. ;-)
gruvin May 28, 2014
6f9b24f
Removed feature/serial2 comimentary from README.md.
gruvin May 28, 2014
6dd44c2
Actually removed ALL the added README text this time. My bad.
gruvin May 28, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Spark Core Firmware [![Backlog](https://badge.waffle.io/spark/core-firmware.png?label=backlog&title=backlog)](https://waffle.io/spark/core-firmware)


This is the main source code repository of the Spark Core firmware libraries.

This firmware depends on two other libraries: the [Spark Common Library](http://www.github.com/spark/core-common-lib) and the [Spark Communication Library](http://www.github.com/spark/core-communication-lib)
Expand Down
Binary file modified build/core-firmware.bin
Binary file not shown.
Binary file modified build/core-firmware.elf
Binary file not shown.
9,040 changes: 4,532 additions & 4,508 deletions build/core-firmware.hex

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions build/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ include $(SRC_MAKEFILES)
# Paths to dependant projects, referenced from root of this project
LIB_CORE_COMMON_PATH = ../core-common-lib
LIB_CORE_COMMUNICATION_PATH = ../core-communication-lib
LIB_CORE_LIBRARIES_PATH = libraries/

# Include directoris for optional "libraries" (eg. Serial2.h)
INCLUDE_DIRS += $(LIB_CORE_LIBRARIES_PATH)/Serial2

# Additional include directories, applied to objects built for this target.
INCLUDE_DIRS += $(LIB_CORE_COMMON_PATH)/CMSIS/Include
Expand Down
31 changes: 16 additions & 15 deletions inc/spark_wiring_usartserial.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,46 @@ typedef struct Ring_Buffer
} Ring_Buffer;

typedef enum USART_Num_Def {
USART_1 = 0,
USART_2
USART_TX_RX =0,
USART_D1_D0
} USART_Num_Def;

#define TOTAL_USARTS 2

#define GPIO_Remap_None 0

typedef struct STM32_USART_Info {
USART_TypeDef* usart_peripheral;
__IO uint32_t* usart_apbReg;
uint32_t usart_clock_en;

// buffer pointers need to be in global scope for int handler access
Ring_Buffer* usart_rx_buffer;
Ring_Buffer* usart_tx_buffer;

IRQn usart_int_n;

uint16_t usart_tx_pin;
uint16_t usart_rx_pin;

uint32_t usart_pin_remap;

// Buffer pointers. These need to be global for IRQ handler access
Ring_Buffer* usart_tx_buffer;
Ring_Buffer* usart_rx_buffer;

} STM32_USART_Info;
extern STM32_USART_Info USART_MAP[TOTAL_USARTS];

extern STM32_Pin_Info PIN_MAP[];

class USARTSerial : public Stream
{
protected:
private:
static USART_InitTypeDef USART_InitStructure;
static bool USARTSerial_Enabled;
bool transmitting;
Ring_Buffer __rx_buffer;
Ring_Buffer __tx_buffer;
Ring_Buffer* _rx_buffer;
Ring_Buffer* _tx_buffer;
STM32_USART_Info* myUSART;
Ring_Buffer _rx_buffer;
Ring_Buffer _tx_buffer;
STM32_USART_Info *usartMap; // pointer to USART_MAP[] containing USART peripheral register locations (etc)

public:
USARTSerial(USART_Num_Def usartNum);
USARTSerial(STM32_USART_Info *usartMapPtr);
virtual ~USARTSerial() {};
void begin(unsigned long);
void begin(unsigned long, uint8_t);
Expand All @@ -102,7 +103,7 @@ class USARTSerial : public Stream

};

extern USARTSerial Serial1; // USART2 on PA2/3
extern USARTSerial Serial1; // USART2 on PA2/3 (Spark TX, RX)
extern USARTSerial Serial2; // USART1 on alternate PB6/7 (Spark D1, D0)

#endif
Binary file added libraries/Serial2/.Serial2.h.swp
Binary file not shown.
11 changes: 11 additions & 0 deletions libraries/Serial2/Serial2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef __LIB_SERIAL2_H
#define __LIB_SERIAL2_H

#include "spark_wiring_usartserial.h"

// instantiate Serial2
USARTSerial Serial2(&USART_MAP[USART_D1_D0]);

#endif


13 changes: 0 additions & 13 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,12 @@ void setup()
Spark.function("analogread", tinkerAnalogRead);
Spark.function("analogwrite", tinkerAnalogWrite);

Serial1.begin(9600);
Serial2.begin(9600);

}

/* This function loops forever --------------------------------------------*/
void loop()
{
//This will run in a loop
static int x = 0;
Serial1.print("TestX ");
Serial1.println(x++, DEC);

Serial2.print("TestZ ");
Serial2.println(x++, DEC);
// Serial2.write('Z');

delay(500);

}

/*******************************************************************************
Expand Down
Loading