moved f4ll_cpp imto its own namespace
moved strutil to the application
This commit is contained in:
parent
0e09fd9a7a
commit
8c62136773
21 changed files with 70 additions and 27 deletions
|
@ -27,6 +27,9 @@
|
|||
# define DIAG_INTERRUPT_OUT()
|
||||
#endif
|
||||
|
||||
namespace f4ll_cpp
|
||||
{
|
||||
|
||||
void Crc_StartNextTask(struct crcstatus_t *status);
|
||||
|
||||
|
||||
|
@ -188,3 +191,4 @@ void CrcScheduler::_HandleDmaIrq()
|
|||
DIAG_INTERRUPT_OUT();
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
#include <platform/crc_ll.h>
|
||||
#include <f4ll_cpp/dmahelper.h>
|
||||
|
||||
namespace f4ll_cpp
|
||||
{
|
||||
|
||||
class CrcScheduler {
|
||||
public:
|
||||
struct ICrcCallback {
|
||||
|
@ -64,5 +67,6 @@ private:
|
|||
crcslot_t *m_firstSlot;
|
||||
};
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* CRC_HANDLER_H_ */
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
#define MOCKABLE(x) x
|
||||
#endif
|
||||
|
||||
namespace f4ll_cpp
|
||||
{
|
||||
|
||||
DmaHelper::DmaHelper(DMA_TypeDef *dma, uint32_t stream)
|
||||
{
|
||||
m_dma = dma;
|
||||
|
@ -80,3 +83,4 @@ uint32_t DmaHelper::_GetTcMask(uint32_t stream)
|
|||
return tcMasks[stream];
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
#define DECLARE_MOCK(x)
|
||||
#endif
|
||||
|
||||
namespace f4ll_cpp
|
||||
{
|
||||
|
||||
class DmaHelper {
|
||||
public:
|
||||
DmaHelper(DMA_TypeDef *dma, uint32_t stream);
|
||||
|
@ -49,16 +52,6 @@ private:
|
|||
uint32_t m_tcMask;
|
||||
};
|
||||
|
||||
|
||||
#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
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* DMA_HELPER_H_ */
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define RGB2U16(R,G,B) ((R & 0xf8) << 8 | (G & 0xfc) << 3 | (B & 0xf8) >> 3)
|
||||
#define MSBSPLIT(x) ((uint8_t)(x >> 8)), ((uint8_t)x)
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
||||
DMA_TypeDef *dma, uint32_t dmaStream,
|
||||
bool horizontal)
|
||||
|
@ -395,3 +397,5 @@ const uint8_t Ili9341Fsmc::m_font[CHRCOUNT][CHRWIDTH] = {
|
|||
{0x02,0x01,0x02,0x01,0x00,0x00}, // ~
|
||||
{0x00,0x00,0x00,0x00,0x00,0x00}
|
||||
};
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <f4ll_cpp/dmahelper.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>, private DmaHelper
|
||||
{
|
||||
public:
|
||||
|
@ -186,4 +188,6 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <f4ll_cpp/dmahelper.h>
|
||||
#include <f4ll_cpp/memcpydma.h>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
MemcpyDma::MemcpyDma(DMA_TypeDef *dma, uint32_t stream) :
|
||||
DmaHelper(dma, stream),
|
||||
m_busy(false)
|
||||
|
@ -33,3 +35,5 @@ void MemcpyDma::HandleDmaIrq(void)
|
|||
m_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <f4ll_cpp/singleton.h>
|
||||
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
class MemcpyDma : public DmaHelper, public Singleton<MemcpyDma>
|
||||
{
|
||||
public:
|
||||
|
@ -26,5 +28,6 @@ private:
|
|||
volatile bool m_busy;
|
||||
};
|
||||
|
||||
} // namespace f4ll_cpp
|
||||
|
||||
#endif /* MEMCPY_DMA_H_ */
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
|
||||
#define STARTMARKER 0x95
|
||||
|
||||
namespace f4ll_cpp
|
||||
{
|
||||
|
||||
static inline uint32_t RoundUpTo4(uint32_t inp)
|
||||
{
|
||||
return (inp + 3) & 0xfffc;
|
||||
|
@ -280,3 +283,4 @@ void PacketUart::HandleUsartIrq()
|
|||
DIAG_INTERRUPT_OUT();
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#define USART_STATS_DISABLED
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
class PacketUart : public UartBase, public CrcScheduler::ICrcCallback
|
||||
{
|
||||
public:
|
||||
|
@ -100,4 +102,6 @@ private:
|
|||
Buffer rxBuffers[2];
|
||||
};
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* UART_HANDLER_H_ */
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include <f4ll_cpp/uartbase.h>
|
||||
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
template<unsigned int bufSize> class SerialConsole : protected UartBase
|
||||
{
|
||||
public:
|
||||
|
@ -166,4 +168,6 @@ template<unsigned int bufSize> void SerialConsole<bufSize>::SendLine(char const
|
|||
}
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* CONSOLEHANDLER_H_ */
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
template<typename T> class Singleton {
|
||||
public:
|
||||
static T &Instance() { return *m_instance; }
|
||||
|
@ -32,4 +34,6 @@ protected:
|
|||
|
||||
template<typename T> T* Singleton<T>::m_instance = nullptr;
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* SINGLETON_H_ */
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
#include <stdint.h>
|
||||
#include <f4ll_cpp/strutil.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t strcpy_ex(char *dst, char const *src)
|
||||
{
|
||||
size_t ret = 0;
|
||||
do {
|
||||
*dst++ = *src;
|
||||
++ret;
|
||||
} while(*src++);
|
||||
return ret - 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void strrev(char *first, char *last)
|
||||
{
|
||||
char tmp;
|
||||
while(last > first) {
|
||||
tmp = *first;
|
||||
*first++ = *last;
|
||||
*last-- = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
char tochr(const uint8_t in, const uint8_t upper)
|
||||
{
|
||||
return in + ((in < 10) ? '0' : (upper ? 'A' : 'a') - 10);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t uitodec(char* buffer, uint32_t data)
|
||||
{
|
||||
char *b2 = buffer;
|
||||
if(!data) {
|
||||
*b2++ = '0';
|
||||
*b2 = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(data) {
|
||||
*b2++ = (data % 10) + '0';
|
||||
data /= 10;
|
||||
}
|
||||
size_t ret = b2 - buffer;
|
||||
|
||||
*b2-- = 0;
|
||||
|
||||
strrev(buffer, b2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t uitohex(char* buffer, uint32_t data, uint8_t chars)
|
||||
{
|
||||
char *b2 = buffer;
|
||||
size_t ret = 0;
|
||||
|
||||
if(chars == 0xff || !chars)
|
||||
{
|
||||
if(!data) {
|
||||
*b2++ = '0';
|
||||
*b2 = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(data) {
|
||||
uint8_t curval = data & 0x0f;
|
||||
*b2++ = tochr(curval, 1);
|
||||
data >>= 4;
|
||||
}
|
||||
ret = b2 - buffer;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = chars;
|
||||
for(uint8_t pos = 0; pos < (uint8_t)ret; ++pos) {
|
||||
*b2++ = tochr(data & 0x0f, 1);
|
||||
data >>= 4;
|
||||
}
|
||||
|
||||
}
|
||||
*b2-- = 0;
|
||||
strrev(buffer, b2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t itodec(char* buffer, int data)
|
||||
{
|
||||
if(data < 0) {
|
||||
*buffer++ = '-';
|
||||
return uitodec(buffer, -data) + 1;
|
||||
}
|
||||
|
||||
return uitodec(buffer, data);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t itohex(char* buffer, int data)
|
||||
{
|
||||
if(data < 0) {
|
||||
*buffer++ = '-';
|
||||
return uitohex(buffer, -data, 0) + 1;
|
||||
}
|
||||
return uitohex(buffer, data, 0);
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* strutil.h
|
||||
*
|
||||
* Created on: Feb 11, 2017
|
||||
* Author: compi
|
||||
*/
|
||||
|
||||
#ifndef _STM32PLUS_STRUTIL_H_
|
||||
#define _STM32PLUS_STRUTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
size_t strcpy_ex(char *dst, char const *src);
|
||||
size_t uitodec(char* buffer, uint32_t data);
|
||||
size_t uitohex(char* buffer, uint32_t data, uint8_t chars);
|
||||
size_t itodec(char* buffer, int data);
|
||||
size_t itohex(char* buffer, int data);
|
||||
void strrev(char *first, char *last);
|
||||
char tochr(const uint8_t in, const uint8_t upper);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _STM32PLUS_STRUTIL_H_ */
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <f4ll_cpp/uartbase.h>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
UartBase::UartBase(USART_TypeDef *uart, DMA_TypeDef *dma, uint32_t stream_rx, uint32_t stream_tx)
|
||||
: m_uart(uart)
|
||||
, 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());
|
||||
}
|
||||
|
||||
} // f4ll_cpp
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include <platform/usart_ll.h>
|
||||
#include <f4ll_cpp/dmahelper.h>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
class UartBase
|
||||
{
|
||||
public:
|
||||
|
@ -24,4 +26,6 @@ protected:
|
|||
DmaHelper m_txDma;
|
||||
};
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* F4LL_CPP_UARTBASE_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue