libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
UTILITY

General Utilities (Ringbuffers, FIFOs, LED Colors, etc.) More...

Detailed Description

General Utilities (Ringbuffers, FIFOs, LED Colors, etc.)

A MappedValue that maps an list of strings linearly.

A MappedValue that maps an int value linearly.

A MappedValue that maps a float value using various mapping functions.

Abstract base class for a value that is mapped to a 0..1 normalized range.

A safe and convenient statically allocated string with constexpr powers.

CPU load metering.

Author
jelliesen

To measure the CPU load of your audio processing, create a CpuLoadMeter and initialize it with your block size and sample rate. Then at the beginning of the audio callback, call OnBlockStart(), and at the end of the audio callback, call OnBlockEnd(). You can then read out the minimum, maximum and average CPU load.

Author
jelliesen

This string class is statically allocated. All of its functions can be evaluated at compile time through the power of constexpr.

Author
jelliesen

Namespaces

namespace  daisy
 Hardware defines and helpers for daisy field platform.
 

Classes

class  daisy::Random
 True Random Number Generator access. More...
 
struct  DSY_SD_CardInfoTypeDef
 
class  daisy::Color
 
struct  FontDef
 
class  daisy::RingBuffer< T, size >
 
class  daisy::RingBuffer< T, 0 >
 

Macros

#define DMA_BUFFER_MEM_SECTION   __attribute__((section(".sram1_bss")))
 
#define DTCM_MEM_SECTION   __attribute__((section(".dtcmram_bss")))
 
#define FBIPMAX   0.999985f
 
#define FBIPMIN   (-FBIPMAX)
 
#define U82F_SCALE   0.0078740f
 
#define F2U8_SCALE   127.0f
 
#define S82F_SCALE   0.0078125f
 
#define F2S8_SCALE   127.0f
 
#define S162F_SCALE   3.0517578125e-05f
 
#define F2S16_SCALE   32767.0f
 
#define F2S24_SCALE   8388608.0f
 
#define S242F_SCALE   1.192092896e-07f
 
#define S24SIGN   0x800000
 
#define S322F_SCALE   4.6566129e-10f
 
#define F2S32_SCALE   2147483647.f
 
#define OUT_L   out[0]
 
#define OUT_R   out[1]
 
#define IN_L   in[0]
 
#define IN_R   in[1]
 
#define BSP_SD_CardInfo   DSY_SD_CardInfoTypeDef
 
#define MSD_OK   ((uint8_t)0x00)
 
#define MSD_ERROR   ((uint8_t)0x01)
 
#define MSD_ERROR_SD_NOT_PRESENT   ((uint8_t)0x02)
 
#define SD_TRANSFER_OK   ((uint8_t)0x00)
 
#define SD_TRANSFER_BUSY   ((uint8_t)0x01)
 
#define SD_PRESENT   ((uint8_t)0x01)
 
#define SD_NOT_PRESENT   ((uint8_t)0x00)
 
#define SD_DATATIMEOUT   ((uint32_t)100000000)
 

Functions

FORCE_INLINE float cube (float x)
 
FORCE_INLINE float u82f (uint8_t x)
 
FORCE_INLINE uint8_t f2u8 (float x)
 
FORCE_INLINE float s82f (int8_t x)
 
FORCE_INLINE int8_t f2s8 (float x)
 
FORCE_INLINE float s162f (int16_t x)
 
FORCE_INLINE int16_t f2s16 (float x)
 
FORCE_INLINE float s242f (int32_t x)
 
FORCE_INLINE int32_t f2s24 (float x)
 
FORCE_INLINE float s322f (int32_t x)
 
FORCE_INLINE int32_t f2s32 (float x)
 
uint8_t BSP_SD_Init (void)
 
uint8_t BSP_SD_ITConfig (void)
 
uint8_t BSP_SD_ReadBlocks (uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
 
uint8_t BSP_SD_WriteBlocks (uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
 
uint8_t BSP_SD_ReadBlocks_DMA (uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
 
uint8_t BSP_SD_WriteBlocks_DMA (uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
 
uint8_t BSP_SD_Erase (uint32_t StartAddr, uint32_t EndAddr)
 
uint8_t BSP_SD_GetCardState (void)
 
void BSP_SD_GetCardInfo (DSY_SD_CardInfoTypeDef *CardInfo)
 
uint8_t BSP_SD_IsDetected (void)
 
void BSP_SD_AbortCallback (void)
 
void BSP_SD_WriteCpltCallback (void)
 
void BSP_SD_ReadCpltCallback (void)
 
void dsy_get_unique_id (uint32_t *w0, uint32_t *w1, uint32_t *w2)
 

Variables

FontDef Font_4x6
 
FontDef Font_4x8
 
FontDef Font_5x8
 
FontDef Font_6x7
 
FontDef Font_6x8
 
FontDef Font_7x10
 
FontDef Font_11x18
 
FontDef Font_16x26
 

Macro Definition Documentation

◆ BSP_SD_CardInfo

#define BSP_SD_CardInfo   DSY_SD_CardInfoTypeDef

&

◆ DMA_BUFFER_MEM_SECTION

#define DMA_BUFFER_MEM_SECTION   __attribute__((section(".sram1_bss")))

Macro for area of memory that is configured as cacheless This should be used primarily for DMA buffers, and the like.

◆ DTCM_MEM_SECTION

#define DTCM_MEM_SECTION   __attribute__((section(".dtcmram_bss")))

THE DTCM RAM section is also non-cached. However, is not suitable for DMA transfers. Performance is on par with internal SRAM w/ cache enabled.

◆ F2S16_SCALE

#define F2S16_SCALE   32767.0f

(2 ** 15) - 1

◆ F2S24_SCALE

#define F2S24_SCALE   8388608.0f

2 ** 23

◆ F2S32_SCALE

#define F2S32_SCALE   2147483647.f

(2 ** 31) - 1

◆ F2S8_SCALE

#define F2S8_SCALE   127.0f

(2 ** 7) - 1

◆ F2U8_SCALE

#define F2U8_SCALE   127.0f

128 - 1

◆ FBIPMAX

#define FBIPMAX   0.999985f

close to 1.0f-LSB at 16 bit

◆ FBIPMIN

#define FBIPMIN   (-FBIPMAX)
  • (1 - LSB)

◆ IN_L

#define IN_L   in[0]

shorthand macro for simplifying the reading of the left channel of a non-interleaved input buffer named in

◆ IN_R

#define IN_R   in[1]

shorthand macro for simplifying the reading of the right channel of a non-interleaved input buffer named in

◆ MSD_ERROR

#define MSD_ERROR   ((uint8_t)0x01)

&

◆ MSD_ERROR_SD_NOT_PRESENT

#define MSD_ERROR_SD_NOT_PRESENT   ((uint8_t)0x02)

&

◆ MSD_OK

#define MSD_OK   ((uint8_t)0x00)

&

◆ OUT_L

#define OUT_L   out[0]

shorthand macro for simplifying the reading of the left channel of a non-interleaved output buffer named out

◆ OUT_R

#define OUT_R   out[1]

shorthand macro for simplifying the reading of the right channel of a non-interleaved output buffer named out

◆ S162F_SCALE

#define S162F_SCALE   3.0517578125e-05f

1 / (2** 15)

◆ S242F_SCALE

#define S242F_SCALE   1.192092896e-07f

1 / (2 ** 23)

◆ S24SIGN

#define S24SIGN   0x800000

2 ** 23

◆ S322F_SCALE

#define S322F_SCALE   4.6566129e-10f

1 / (2** 31)

◆ S82F_SCALE

#define S82F_SCALE   0.0078125f

1 / (2**7)

◆ SD_DATATIMEOUT

#define SD_DATATIMEOUT   ((uint32_t)100000000)

&

◆ SD_NOT_PRESENT

#define SD_NOT_PRESENT   ((uint8_t)0x00)

&

◆ SD_PRESENT

#define SD_PRESENT   ((uint8_t)0x01)

&

◆ SD_TRANSFER_BUSY

#define SD_TRANSFER_BUSY   ((uint8_t)0x01)

&

◆ SD_TRANSFER_OK

#define SD_TRANSFER_OK   ((uint8_t)0x00)

&

◆ U82F_SCALE

#define U82F_SCALE   0.0078740f

1 / 127

Function Documentation

◆ BSP_SD_AbortCallback()

void BSP_SD_AbortCallback ( void  )

These functions can be modified in case the current settings (e.g. DMA stream) need to be changed for specific application needs /n

Abort the callback

◆ BSP_SD_Erase()

uint8_t BSP_SD_Erase ( uint32_t  StartAddr,
uint32_t  EndAddr 
)

Erase a section of memory

Parameters
StartAddrAddress to start erasing at
EndAddrAddress to stop erasing at
Returns
card state, ERROR, etc.

◆ BSP_SD_GetCardInfo()

void BSP_SD_GetCardInfo ( DSY_SD_CardInfoTypeDef CardInfo)
Parameters
*CardInfoPointer to write card info to
Parameters
CardInfo&

◆ BSP_SD_GetCardState()

uint8_t BSP_SD_GetCardState ( void  )
Returns
card state, ERROR, etc.

◆ BSP_SD_Init()

uint8_t BSP_SD_Init ( void  )
Returns
card state, ERROR, etc.

◆ BSP_SD_IsDetected()

uint8_t BSP_SD_IsDetected ( void  )
Returns
Is card detected

◆ BSP_SD_ITConfig()

uint8_t BSP_SD_ITConfig ( void  )
Returns
card state, ERROR, etc.

◆ BSP_SD_ReadBlocks()

uint8_t BSP_SD_ReadBlocks ( uint32_t *  pData,
uint32_t  ReadAddr,
uint32_t  NumOfBlocks,
uint32_t  Timeout 
)
Parameters
*pData&
ReadAddrAddress to read from
NumOfBlocksNumber of blocks to be read
TimeoutTimeout len in ms
Returns
OK ERROR, etc.

◆ BSP_SD_ReadBlocks_DMA()

uint8_t BSP_SD_ReadBlocks_DMA ( uint32_t *  pData,
uint32_t  ReadAddr,
uint32_t  NumOfBlocks 
)

No timeout

Parameters
*pData&
ReadAddrAddress to read from
NumOfBlocksNumber of blocks to be read
Returns
card state, ERROR, etc.

◆ BSP_SD_ReadCpltCallback()

void BSP_SD_ReadCpltCallback ( void  )

Write complete callback

◆ BSP_SD_WriteBlocks()

uint8_t BSP_SD_WriteBlocks ( uint32_t *  pData,
uint32_t  WriteAddr,
uint32_t  NumOfBlocks,
uint32_t  Timeout 
)
Parameters
*pData&
WriteAddrAddress to write to
NumOfBlocksNumber of blocks to be written
TimeoutTimeout len in ms
Returns
card state, ERROR, etc.

◆ BSP_SD_WriteBlocks_DMA()

uint8_t BSP_SD_WriteBlocks_DMA ( uint32_t *  pData,
uint32_t  WriteAddr,
uint32_t  NumOfBlocks 
)

No timeout

Parameters
*pData&
WriteAddrAddress to write to
NumOfBlocksNumber of blocks to be read
Returns
card state, ERROR, etc.

◆ BSP_SD_WriteCpltCallback()

void BSP_SD_WriteCpltCallback ( void  )

Read complete callback

◆ cube()

FORCE_INLINE float cube ( float  x)

Computes cube.

Parameters
xNumber to be cubed
Returns
x ^ 3

◆ dsy_get_unique_id()

void dsy_get_unique_id ( uint32_t *  w0,
uint32_t *  w1,
uint32_t *  w2 
)

Returns 96-bit Unique ID of the MCU

Author
shensley
Date
May 2020 fills the three pointer arguments with the unique ID of the MCU.
Parameters
*w0First pointer
*w1Second pointer
*w2Third pointer

◆ f2s16()

FORCE_INLINE int16_t f2s16 ( float  x)

Converts float to Signed 16-bit

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< close to 1.0f-LSB at 16 bit

< (2 ** 15) - 1

◆ f2s24()

FORCE_INLINE int32_t f2s24 ( float  x)

Converts float to Signed 24-bit

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< close to 1.0f-LSB at 16 bit

< 2 ** 23

◆ f2s32()

FORCE_INLINE int32_t f2s32 ( float  x)

Converts float to Signed 24-bit

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< close to 1.0f-LSB at 16 bit

< (2 ** 31) - 1

◆ f2s8()

FORCE_INLINE int8_t f2s8 ( float  x)

Converts float to Signed 8-bit

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< close to 1.0f-LSB at 16 bit

< (2 ** 7) - 1

◆ f2u8()

FORCE_INLINE uint8_t f2u8 ( float  x)

Converts float to unsigned 8-bit

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< - (1 - LSB)

< close to 1.0f-LSB at 16 bit

< close to 1.0f-LSB at 16 bit

< 128 - 1

< 128 - 1

◆ s162f()

FORCE_INLINE float s162f ( int16_t  x)

Converts Signed 16-bit to float

Parameters
xNumber to be scaled.
Returns
Scaled number.

< 1 / (2** 15)

◆ s242f()

FORCE_INLINE float s242f ( int32_t  x)

Converts Signed 24-bit to float

< 2 ** 23

< 2 ** 23

< 1 / (2 ** 23)

◆ s322f()

FORCE_INLINE float s322f ( int32_t  x)

Converts Signed 32-bit to float

< 1 / (2** 31)

◆ s82f()

FORCE_INLINE float s82f ( int8_t  x)

Converts Signed 8-bit to float

Parameters
xNumber to be scaled.
Returns
Scaled number.

< 1 / (2**7)

◆ u82f()

FORCE_INLINE float u82f ( uint8_t  x)

Converts unsigned 8-bit to float

Parameters
xNumber to be scaled.
Returns
Scaled number.

< 1 / 127

Variable Documentation

◆ Font_11x18

FontDef Font_11x18
extern

&

◆ Font_16x26

FontDef Font_16x26
extern

&

◆ Font_4x6

FontDef Font_4x6
extern

These are the different sizes of fonts (width x height in pixels per character)

◆ Font_4x8

FontDef Font_4x8
extern

◆ Font_5x8

FontDef Font_5x8
extern

◆ Font_6x7

FontDef Font_6x7
extern

◆ Font_6x8

FontDef Font_6x8
extern

◆ Font_7x10

FontDef Font_7x10
extern

&