Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ After CS is enabled, slave awaits 8 bit command from master, slave then transfer
| | |
| --- | --- |
| Chip select pin | D22 (PA0) |
| CPOL | 0 |
| CPHA | 0 |
| CPOL | 1 |
| CPHA | 1 |
| Master | Arduino Mega |
| Slave | STM32 |
| Format | 8 bit command byte + (optional data from slave) (MSB first) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ MEMORY

_estack = 0x20008000;

_siccmram = LOADADDR(.ccmram);

SECTIONS
{
.isr_vector :
Expand All @@ -40,6 +42,17 @@ SECTIONS
_etext = .;

} > FLASH

.ccmram :
{
. = ALIGN(4);
_sccmram = .;
*(.ccmram)
*(.ccmram*)

. = ALIGN(4);
_eccmram = .;
} > CCMRAM AT > FLASH

.ARM.extab :
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ void SystemInit();
void __libc_init_array();
int main();

extern void *_siccmram, *_sccmram, *_eccmram;
extern void *_sidata, *_sdata, *_edata;
extern void *_sbss, *_ebss;

Expand All @@ -810,6 +811,9 @@ void __attribute__((naked, noreturn)) Reset_Handler()
for (pSource = &_sidata, pDest = &_sdata; pDest != &_edata; pSource++, pDest++)
*pDest = *pSource;

for (pSource = &_siccmram, pDest = &_sccmram; pDest != &_eccmram; pSource++, pDest++)
*pDest = *pSource;

for (pDest = &_sbss; pDest != &_ebss; pDest++)
*pDest = 0;

Expand Down
12 changes: 6 additions & 6 deletions target-code/EncoderTracker/app_code/app/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void App::ConfigSpi()

spi.Initialize(SpiSlave::_Spi1);
spi.ConfigPins(spiPinConfig);
spi.ConfigMode(SpiSlave::_Cpol0Cpha0);
spi.ConfigMode(SpiSlave::_Cpol1Cpha1);
spi.ConfigFrame(SpiSlave::_MsbFirst, SpiSlave::_8Bit);
spi.ConfigFifoRecThreshold(SpiSlave::_1Byte);
spi.ConfigBaudRatePrescaler(SpiSlave::_Fpclk8);
Expand Down Expand Up @@ -129,7 +129,7 @@ void App::ConfigExtInt()

///Reads the encoder counts from the Timer modules and converts them into 32bit signed values
///This function should be called in the main loop
void App::Execute()
__ccm void App::Execute()
{
uint16_t encCount = 0;
int32_t encoderDataTemp = 0;
Expand All @@ -153,7 +153,7 @@ void App::Execute()


///Interprets and executes command from the SPI master
void App::ServeSpi()
__ccm void App::ServeSpi()
{
spi.Enable();
uint8_t header = 0;
Expand All @@ -175,7 +175,7 @@ void App::ServeSpi()


///Transmits selected encoder values to the SPI master
void App::SendEncoderVals(uint8_t header)
__ccm void App::SendEncoderVals(uint8_t header)
{
uint8_t encSelector = header >> enc_offset;
uint16_t numTxEncoders = 0;
Expand All @@ -195,7 +195,7 @@ void App::SendEncoderVals(uint8_t header)


///Resets selected encoder values to 0
void App::ClearEncoderVals(uint8_t header)
__ccm void App::ClearEncoderVals(uint8_t header)
{
uint8_t encSelector = header >> enc_offset;

Expand All @@ -212,7 +212,7 @@ void App::ClearEncoderVals(uint8_t header)


///Reverses byte endianness of data
void App::ReverseEndian(int32_t* num)
__ccm void App::ReverseEndian(int32_t* num)
{
uint8_t* temp1 = (uint8_t*)num;
uint8_t ch = 0;
Expand Down
2 changes: 1 addition & 1 deletion target-code/EncoderTracker/app_code/app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(void)

extern "C"
{
void EXTI4_IRQHandler()
__attribute__((section(".ccmram"))) void EXTI4_IRQHandler()
{
app.ServeSpi();
app.ExtIntClear();
Expand Down
2 changes: 2 additions & 0 deletions target-code/EncoderTracker/app_code/hal/inc/HalHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
#include <stdint.h>
#include "stm32f3xx.h"

#define __ccm __attribute__((section(".ccmram")))

#endif
8 changes: 4 additions & 4 deletions target-code/EncoderTracker/app_code/hal/src/SpiSlave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void SpiSlave::ConfigDma(bool isEnableTxDma, bool isEnableRxDma)



uint8_t SpiSlave::ReadWriteByte(uint8_t txData)
__ccm uint8_t SpiSlave::ReadWriteByte(uint8_t txData)
{
while (!base->SR & SPI_SR_TXE && IsSelected());
base->DR = txData;
Expand All @@ -130,7 +130,7 @@ uint8_t SpiSlave::ReadWriteByte(uint8_t txData)
}

///Receive data from SPI port
void SpiSlave::Read(uint8_t* rxData, uint16_t rxSize)
__ccm void SpiSlave::Read(uint8_t* rxData, uint16_t rxSize)
{
while (0 < rxSize && IsSelected() )
{
Expand All @@ -155,7 +155,7 @@ void SpiSlave::Read(uint8_t* rxData, uint16_t rxSize)


///Send data to SPI port
void SpiSlave::Write(const uint8_t* txData, uint16_t txSize)
__ccm void SpiSlave::Write(const uint8_t* txData, uint16_t txSize)
{
while (0 < txSize && IsSelected() )
{
Expand Down Expand Up @@ -185,7 +185,7 @@ void SpiSlave::Write(const uint8_t* txData, uint16_t txSize)


///Simultaneously send data and receive data
void SpiSlave::ReadAndWrite(uint8_t * rxData, const uint8_t * txData, uint16_t size)
__ccm void SpiSlave::ReadAndWrite(uint8_t * rxData, const uint8_t * txData, uint16_t size)
{
if (__null == rxData || __null == txData) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ void SystemInit();
void __libc_init_array();
int main();

extern void *_siccmram, *_sccmram, *_eccmram;
extern void *_sidata, *_sdata, *_edata;
extern void *_sbss, *_ebss;

Expand All @@ -811,6 +812,9 @@ void __attribute__((naked, noreturn)) Reset_Handler()
for (pSource = &_sidata, pDest = &_sdata; pDest != &_edata; pSource++, pDest++)
*pDest = *pSource;

for (pSource = &_siccmram, pDest = &_sccmram; pDest != &_eccmram; pSource++, pDest++)
*pDest = *pSource;

for (pDest = &_sbss; pDest != &_ebss; pDest++)
*pDest = 0;

Expand Down