Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
8c62136773 | |||
0e09fd9a7a | |||
ba34922951 |
21 changed files with 85 additions and 43 deletions
|
@ -6,16 +6,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f4ll_cpp/ili9341.h>
|
#include <f4ll_cpp/ili9341.h>
|
||||||
#include <f4ll_cpp/strutil.h>
|
|
||||||
#include <application.h>
|
#include <application.h>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "strutil.h"
|
||||||
|
|
||||||
#define BORDER 60
|
#define BORDER 60
|
||||||
#define BARWIDTH 2
|
#define BARWIDTH 2
|
||||||
|
|
||||||
|
using namespace f4ll_cpp;
|
||||||
|
|
||||||
void MainLoop()
|
void MainLoop()
|
||||||
{
|
{
|
||||||
|
@ -57,8 +57,6 @@ Application::Application()
|
||||||
|
|
||||||
void Application::Loop()
|
void Application::Loop()
|
||||||
{
|
{
|
||||||
char buffer[128];
|
|
||||||
|
|
||||||
Ili9341Fsmc &lcd(Ili9341Fsmc::Init(nullptr, nullptr, DMA2, LL_DMA_STREAM_4, false));
|
Ili9341Fsmc &lcd(Ili9341Fsmc::Init(nullptr, nullptr, DMA2, LL_DMA_STREAM_4, false));
|
||||||
lcd.SetScrollMode(true);
|
lcd.SetScrollMode(true);
|
||||||
|
|
||||||
|
@ -71,13 +69,13 @@ void Application::Loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(m_received && m_transmitted) {
|
if(m_lineReceived && m_transmissionCompleted) {
|
||||||
m_transmitted = false;
|
m_transmissionCompleted = false;
|
||||||
const char *line = const_cast<const char*>(m_rcvdBuffer->buffer);
|
const char *line = const_cast<const char*>(m_rcvdBuffer->buffer);
|
||||||
m_console.SendLine(line, m_rcvdBuffer->len);
|
m_console.SendLine(line, m_rcvdBuffer->len);
|
||||||
lcd.Print(line);
|
lcd.Print(line);
|
||||||
lcd.Print("\r\n", 2);
|
lcd.Print("\r\n", 2);
|
||||||
m_received = false;
|
m_lineReceived = false;
|
||||||
m_rcvdBuffer->busy = false;
|
m_rcvdBuffer->busy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,25 +86,25 @@ void Application::Loop()
|
||||||
|
|
||||||
uint16_t x = ReadTouch(SPI2, true);
|
uint16_t x = ReadTouch(SPI2, true);
|
||||||
uint16_t y = ReadTouch(SPI2, false);
|
uint16_t y = ReadTouch(SPI2, false);
|
||||||
unsigned len = strcpy_ex(buffer, "X: ");
|
unsigned len = strcpy_ex(m_appBuffer, "X: ");
|
||||||
len += uitodec(buffer+len, x);
|
len += uitodec(m_appBuffer+len, x);
|
||||||
len += strcpy_ex(buffer + len, ", Y: ");
|
len += strcpy_ex(m_appBuffer + len, ", Y: ");
|
||||||
len += uitodec(buffer + len, y);
|
len += uitodec(m_appBuffer + len, y);
|
||||||
len += strcpy_ex(buffer + len, "\r\n");
|
len += strcpy_ex(m_appBuffer + len, "\r\n");
|
||||||
lcd.Print(buffer, len);
|
lcd.Print(m_appBuffer, len);
|
||||||
m_console.SendLine(buffer, len);
|
m_console.SendLine(m_appBuffer, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::LineReceived(void *userParam, SerialConsole<257>::Buffer *buffer)
|
void Application::LineReceived(void *userParam, SerialConsole<257>::Buffer *buffer)
|
||||||
{
|
{
|
||||||
m_received = true;
|
m_lineReceived = true;
|
||||||
m_rcvdBuffer = buffer;
|
m_rcvdBuffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::TransmissionComplete(void *userParam, SerialConsole<257>::Buffer *buffer)
|
void Application::TransmissionComplete(void *userParam, SerialConsole<257>::Buffer *buffer)
|
||||||
{
|
{
|
||||||
m_transmitted = true;
|
m_transmissionCompleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,25 +23,26 @@ void MainLoop();
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
struct GlobalsInitializer {
|
struct GlobalsInitializer {
|
||||||
GlobalsInitializer(SerialConsole<257> *console) {
|
GlobalsInitializer(f4ll_cpp::SerialConsole<257> *console) {
|
||||||
g_console = console;
|
g_console = console;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Application : public GlobalsInitializer, public SerialConsole<257>::ISerialConsoleCallback {
|
class Application : public GlobalsInitializer, public f4ll_cpp::SerialConsole<257>::ISerialConsoleCallback {
|
||||||
public:
|
public:
|
||||||
Application();
|
Application();
|
||||||
void Loop();
|
void Loop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void LineReceived(void *userParam, SerialConsole<257>::Buffer *buffer);
|
virtual void LineReceived(void *userParam, f4ll_cpp::SerialConsole<257>::Buffer *buffer);
|
||||||
virtual void TransmissionComplete(void *userParam, SerialConsole<257>::Buffer *buffer);
|
virtual void TransmissionComplete(void *userParam, f4ll_cpp::SerialConsole<257>::Buffer *buffer);
|
||||||
|
|
||||||
SerialConsole<257> m_console;
|
f4ll_cpp::SerialConsole<257> m_console;
|
||||||
volatile bool m_received = false;
|
volatile bool m_lineReceived = false;
|
||||||
volatile SerialConsole<257>::Buffer *m_rcvdBuffer;
|
volatile f4ll_cpp::SerialConsole<257>::Buffer *m_rcvdBuffer;
|
||||||
|
char m_appBuffer[128];
|
||||||
|
|
||||||
volatile bool m_transmitted = true;
|
volatile bool m_transmissionCompleted = true;
|
||||||
};
|
};
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
SerialConsole<257> *g_console = nullptr;
|
f4ll_cpp::SerialConsole<257> *g_console = nullptr;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
||||||
extern SerialConsole<257> *g_console;
|
extern f4ll_cpp::SerialConsole<257> *g_console;
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
void HandleLcdDmaIrq()
|
void HandleLcdDmaIrq()
|
||||||
{
|
{
|
||||||
// DMA2 Stream4
|
// DMA2 Stream4
|
||||||
Ili9341Fsmc::HandleDmaIrq(&Ili9341Fsmc::Instance());
|
f4ll_cpp::Ili9341Fsmc::HandleDmaIrq(&f4ll_cpp::Ili9341Fsmc::Instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleConsoleRxDmaIrq()
|
void HandleConsoleRxDmaIrq()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <f4ll_cpp/strutil.h>
|
#include "strutil.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
size_t strcpy_ex(char *dst, char const *src)
|
size_t strcpy_ex(char *dst, char const *src)
|
|
@ -4,9 +4,8 @@
|
||||||
* Created on: Feb 11, 2017
|
* Created on: Feb 11, 2017
|
||||||
* Author: compi
|
* Author: compi
|
||||||
*/
|
*/
|
||||||
|
#ifndef _STRUTIL_H_
|
||||||
#ifndef _STM32PLUS_STRUTIL_H_
|
#define _STRUTIL_H_
|
||||||
#define _STM32PLUS_STRUTIL_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -28,4 +27,5 @@ char tochr(const uint8_t in, const uint8_t upper);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _STM32PLUS_STRUTIL_H_ */
|
|
||||||
|
#endif // _STRUTIL_H_
|
|
@ -27,6 +27,9 @@
|
||||||
# define DIAG_INTERRUPT_OUT()
|
# define DIAG_INTERRUPT_OUT()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace f4ll_cpp
|
||||||
|
{
|
||||||
|
|
||||||
void Crc_StartNextTask(struct crcstatus_t *status);
|
void Crc_StartNextTask(struct crcstatus_t *status);
|
||||||
|
|
||||||
|
|
||||||
|
@ -188,3 +191,4 @@ void CrcScheduler::_HandleDmaIrq()
|
||||||
DIAG_INTERRUPT_OUT();
|
DIAG_INTERRUPT_OUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
#include <platform/crc_ll.h>
|
#include <platform/crc_ll.h>
|
||||||
#include <f4ll_cpp/dmahelper.h>
|
#include <f4ll_cpp/dmahelper.h>
|
||||||
|
|
||||||
|
namespace f4ll_cpp
|
||||||
|
{
|
||||||
|
|
||||||
class CrcScheduler {
|
class CrcScheduler {
|
||||||
public:
|
public:
|
||||||
struct ICrcCallback {
|
struct ICrcCallback {
|
||||||
|
@ -64,5 +67,6 @@ private:
|
||||||
crcslot_t *m_firstSlot;
|
crcslot_t *m_firstSlot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif /* CRC_HANDLER_H_ */
|
#endif /* CRC_HANDLER_H_ */
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#define MOCKABLE(x) x
|
#define MOCKABLE(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace f4ll_cpp
|
||||||
|
{
|
||||||
|
|
||||||
DmaHelper::DmaHelper(DMA_TypeDef *dma, uint32_t stream)
|
DmaHelper::DmaHelper(DMA_TypeDef *dma, uint32_t stream)
|
||||||
{
|
{
|
||||||
m_dma = dma;
|
m_dma = dma;
|
||||||
|
@ -80,3 +83,4 @@ uint32_t DmaHelper::_GetTcMask(uint32_t stream)
|
||||||
return tcMasks[stream];
|
return tcMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
#define DECLARE_MOCK(x)
|
#define DECLARE_MOCK(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace f4ll_cpp
|
||||||
|
{
|
||||||
|
|
||||||
class DmaHelper {
|
class DmaHelper {
|
||||||
public:
|
public:
|
||||||
DmaHelper(DMA_TypeDef *dma, uint32_t stream);
|
DmaHelper(DMA_TypeDef *dma, uint32_t stream);
|
||||||
|
@ -49,16 +52,6 @@ private:
|
||||||
uint32_t m_tcMask;
|
uint32_t m_tcMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
#ifdef UNITTEST
|
|
||||||
DECLARE_MOCK(Dma_GetIsReg);
|
|
||||||
DECLARE_MOCK(Dma_GetIfcReg);
|
|
||||||
DECLARE_MOCK(Dma_GetDmeMask);
|
|
||||||
DECLARE_MOCK(Dma_GetTeMask);
|
|
||||||
DECLARE_MOCK(Dma_GetHtMask);
|
|
||||||
DECLARE_MOCK(Dma_GetTcMask);
|
|
||||||
DECLARE_MOCK(Dma_GetFeMask);
|
|
||||||
DECLARE_MOCK(Dma_Init);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* DMA_HELPER_H_ */
|
#endif /* DMA_HELPER_H_ */
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#define RGB2U16(R,G,B) ((R & 0xf8) << 8 | (G & 0xfc) << 3 | (B & 0xf8) >> 3)
|
#define RGB2U16(R,G,B) ((R & 0xf8) << 8 | (G & 0xfc) << 3 | (B & 0xf8) >> 3)
|
||||||
#define MSBSPLIT(x) ((uint8_t)(x >> 8)), ((uint8_t)x)
|
#define MSBSPLIT(x) ((uint8_t)(x >> 8)), ((uint8_t)x)
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
||||||
DMA_TypeDef *dma, uint32_t dmaStream,
|
DMA_TypeDef *dma, uint32_t dmaStream,
|
||||||
bool horizontal)
|
bool horizontal)
|
||||||
|
@ -395,3 +397,5 @@ const uint8_t Ili9341Fsmc::m_font[CHRCOUNT][CHRWIDTH] = {
|
||||||
{0x02,0x01,0x02,0x01,0x00,0x00}, // ~
|
{0x02,0x01,0x02,0x01,0x00,0x00}, // ~
|
||||||
{0x00,0x00,0x00,0x00,0x00,0x00}
|
{0x00,0x00,0x00,0x00,0x00,0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <f4ll_cpp/dmahelper.h>
|
#include <f4ll_cpp/dmahelper.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>, private DmaHelper
|
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>, private DmaHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -186,4 +188,6 @@ public:
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <f4ll_cpp/dmahelper.h>
|
#include <f4ll_cpp/dmahelper.h>
|
||||||
#include <f4ll_cpp/memcpydma.h>
|
#include <f4ll_cpp/memcpydma.h>
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
MemcpyDma::MemcpyDma(DMA_TypeDef *dma, uint32_t stream) :
|
MemcpyDma::MemcpyDma(DMA_TypeDef *dma, uint32_t stream) :
|
||||||
DmaHelper(dma, stream),
|
DmaHelper(dma, stream),
|
||||||
m_busy(false)
|
m_busy(false)
|
||||||
|
@ -33,3 +35,5 @@ void MemcpyDma::HandleDmaIrq(void)
|
||||||
m_busy = false;
|
m_busy = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include <f4ll_cpp/singleton.h>
|
#include <f4ll_cpp/singleton.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
class MemcpyDma : public DmaHelper, public Singleton<MemcpyDma>
|
class MemcpyDma : public DmaHelper, public Singleton<MemcpyDma>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -26,5 +28,6 @@ private:
|
||||||
volatile bool m_busy;
|
volatile bool m_busy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace f4ll_cpp
|
||||||
|
|
||||||
#endif /* MEMCPY_DMA_H_ */
|
#endif /* MEMCPY_DMA_H_ */
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
|
|
||||||
#define STARTMARKER 0x95
|
#define STARTMARKER 0x95
|
||||||
|
|
||||||
|
namespace f4ll_cpp
|
||||||
|
{
|
||||||
|
|
||||||
static inline uint32_t RoundUpTo4(uint32_t inp)
|
static inline uint32_t RoundUpTo4(uint32_t inp)
|
||||||
{
|
{
|
||||||
return (inp + 3) & 0xfffc;
|
return (inp + 3) & 0xfffc;
|
||||||
|
@ -280,3 +283,4 @@ void PacketUart::HandleUsartIrq()
|
||||||
DIAG_INTERRUPT_OUT();
|
DIAG_INTERRUPT_OUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#define USART_STATS_DISABLED
|
#define USART_STATS_DISABLED
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
class PacketUart : public UartBase, public CrcScheduler::ICrcCallback
|
class PacketUart : public UartBase, public CrcScheduler::ICrcCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -100,4 +102,6 @@ private:
|
||||||
Buffer rxBuffers[2];
|
Buffer rxBuffers[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif /* UART_HANDLER_H_ */
|
#endif /* UART_HANDLER_H_ */
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include <f4ll_cpp/uartbase.h>
|
#include <f4ll_cpp/uartbase.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
template<unsigned int bufSize> class SerialConsole : protected UartBase
|
template<unsigned int bufSize> class SerialConsole : protected UartBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -166,4 +168,6 @@ template<unsigned int bufSize> void SerialConsole<bufSize>::SendLine(char const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif /* CONSOLEHANDLER_H_ */
|
#endif /* CONSOLEHANDLER_H_ */
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
template<typename T> class Singleton {
|
template<typename T> class Singleton {
|
||||||
public:
|
public:
|
||||||
static T &Instance() { return *m_instance; }
|
static T &Instance() { return *m_instance; }
|
||||||
|
@ -32,4 +34,6 @@ protected:
|
||||||
|
|
||||||
template<typename T> T* Singleton<T>::m_instance = nullptr;
|
template<typename T> T* Singleton<T>::m_instance = nullptr;
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif /* SINGLETON_H_ */
|
#endif /* SINGLETON_H_ */
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include <f4ll_cpp/uartbase.h>
|
#include <f4ll_cpp/uartbase.h>
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
UartBase::UartBase(USART_TypeDef *uart, DMA_TypeDef *dma, uint32_t stream_rx, uint32_t stream_tx)
|
UartBase::UartBase(USART_TypeDef *uart, DMA_TypeDef *dma, uint32_t stream_rx, uint32_t stream_tx)
|
||||||
: m_uart(uart)
|
: m_uart(uart)
|
||||||
, m_rxDma(dma, stream_rx)
|
, m_rxDma(dma, stream_rx)
|
||||||
|
@ -44,3 +46,4 @@ void UartBase::SetupTransmit(void *buffer, uint16_t length)
|
||||||
LL_DMA_EnableStream(m_txDma.GetDma(), m_txDma.GetStream());
|
LL_DMA_EnableStream(m_txDma.GetDma(), m_txDma.GetStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#include <platform/usart_ll.h>
|
#include <platform/usart_ll.h>
|
||||||
#include <f4ll_cpp/dmahelper.h>
|
#include <f4ll_cpp/dmahelper.h>
|
||||||
|
|
||||||
|
namespace f4ll_cpp {
|
||||||
|
|
||||||
class UartBase
|
class UartBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -24,4 +26,6 @@ protected:
|
||||||
DmaHelper m_txDma;
|
DmaHelper m_txDma;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // f4ll_cpp
|
||||||
|
|
||||||
#endif /* F4LL_CPP_UARTBASE_H_ */
|
#endif /* F4LL_CPP_UARTBASE_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue