Pervasive Displays Library Suite - Reference Manual 9.0.3
Library for Pervasive Displays e-paper screens, extension boards and development kits
Loading...
Searching...
No Matches
hV_SDK_Peripherals.h File Reference

Light hardware abstraction layer for peripherals. More...

#include <Arduino.h>
#include <stdint.h>
#include <stdio.h>
#include <stdarg.h>
#include <Wire.h>
#include <SPI.h>
Include dependency graph for hV_SDK_Peripherals.h:
This graph shows which files directly or indirectly include this file:

Macros

#define hV_SDK_PERIPHERALS_RELEASE   902
 Release.
 
Specific configuration

SDK library

See also
References

Other libraries

#define hV_SDK_Serial   Serial
 FRAM management.
 
#define hV_SDK_Serial_Speed   115200
 Serial port speed.
 
#define hV_SDK_Wire   Wire
 Wire configuration.
 
#define hV_SDK_SPI   SPI
 SPI configuration.
 
#define SPI_SPEED_4_MHz   4000000
 SPI speed.
 
#define SPI_SPEED_8_MHz   8000000
 SPI configuration.
 
#define SPI_SPEED_16_MHz   16000000
 SPI configuration.
 
#define hV_SDK_SPI_SPEED   SPI_SPEED_8_MHz
 SPI configuration.
 
#define hV_SDK_SPI_MOSI   MOSI
 SPI pins.
 
#define hV_SDK_SPI_MISO   MISO
 SPI configuration.
 
#define hV_SDK_SPI_SCK   SCK
 SPI configuration.
 

Functions

template<typename T>
void hV_SDK_Serial_print (T text)
 Print to serial console.
 
template<typename T>
void hV_SDK_Serial_println (T text)
 Print to serial console with cr-lf at the end.
 
General
void hV_SDK_begin ()
 General initialisation.
 
void hV_SDK_exit (uint8_t code=0)
 General exit.
 
GPIO
void hV_SDK_GPIO_begin (void)
 GPIO initialisation.
 
void hV_SDK_GPIO_define (uint8_t pin, uint8_t mode)
 Define GPIO mode.
 
void hV_SDK_GPIO_write (uint8_t pin, uint8_t value)
 Write GPIO.
 
uint8_t hV_SDK_GPIO_read (uint8_t pin)
 Read GPIO.
 
Time
void hV_SDK_delayMicroseconds (uint32_t us)
 Microsecond non-blocking delay.
 
void hV_SDK_delayMilliseconds (uint32_t ms)
 Millisecond non-blocking delay.
 
uint32_t hV_SDK_getMilliseconds (void)
 Get milliseconds since start-up.
 
Serial console
void hV_SDK_Serial_begin (uint32_t speed=115200)
 Initialise console.
 
void hV_SDK_Serial_printf (const char *format, va_list args)
 Format and send to console.
 
void hV_SDK_Serial_crlf (void)
 Print carriage-return line-feed.
 
SPI bus
See also
https://www.arduino.cc/en/Reference/SPI
Warning
Energia does not implement beginTransaction...endTransaction
void hV_SDK_SPI_begin (uint32_t speed=8000000)
 Configure and start SPI.
 
void hV_SDK_SPI_end ()
 End SPI.
 
uint8_t hV_SDK_SPI_transfer (uint8_t data)
 Combined write and read of a single byte.
 
void hV_SDK_SPI_transfer (uint8_t *data, size_t size)
 Combined write and read.
 
3-wire SPI bus
Warning
  • Arduino does not support 3-wire PSI, bit-bang simulation
  • Viewer: For compatibility only, not implemented in Linux
Note
hV_SDK_SPI_begin() calls hV_SDK_SPI3_define().
void hV_SDK_SPI3_begin ()
 Configure 3-wire SPI.
 
void hV_SDK_SPI3_end ()
 End 3-wire SPI.
 
void hV_SDK_SPI3_define (uint8_t pinClock=SCK, uint8_t pinData=MOSI)
 Set the 3-wire SPI pins.
 
uint8_t hV_SDK_SPI3_read ()
 Read a single byte.
 
void hV_SDK_SPI3_write (uint8_t data)
 Write a single byte.
 
Wire bus
void hV_SDK_Wire_begin ()
 Configure and start Wire bus.
 
void hV_SDK_Wire_end ()
 End Wire bus.
 
void hV_SDK_Wire_transfer (uint8_t address, uint8_t *dataWrite, size_t sizeWrite, uint8_t *dataRead=0, size_t sizeRead=0)
 Combined write and read.
 
Miscellaneous
uint32_t hV_SDK_random (uint32_t maxNumber)
 Pseudo-random number.
 

Detailed Description

Light hardware abstraction layer for peripherals.

Project Pervasive Displays Library Suite
Based on highView technology

Author
Rei Vilo
Date
21 Jan 2025
Version
902
  • Evaluation edition: for professionals or organisations, evaluation only, no commercial usage
  • Commercial edition: for professionals or organisations, commercial usage

    Deprecated
    Removed synonyms for GPIO (7.0.0)
    Deprecated
    Removed synonyms for Time (7.0.0)
    Deprecated
    Removed synonyms for Serial (7.0.0)
    Deprecated
    Removed synonyms for SPI (7.0.0)
    Deprecated
    Removed synonyms for Wire (7.0.0)

Macro Definition Documentation

◆ hV_SDK_Serial

#define hV_SDK_Serial   Serial

FRAM management.

for MSP430FR MCUs

Serial configuration

Serial port

◆ hV_SDK_Serial_Speed

#define hV_SDK_Serial_Speed   115200

Serial port speed.

Recommended 115200

◆ hV_SDK_SPI

#define hV_SDK_SPI   SPI

SPI configuration.

SPI bus

◆ hV_SDK_SPI_MISO

#define hV_SDK_SPI_MISO   MISO

SPI configuration.

SPI bus

◆ hV_SDK_SPI_MOSI

#define hV_SDK_SPI_MOSI   MOSI

SPI pins.

For default SPI3 configuration

◆ hV_SDK_SPI_SCK

#define hV_SDK_SPI_SCK   SCK

SPI configuration.

SPI bus

◆ hV_SDK_SPI_SPEED

#define hV_SDK_SPI_SPEED   SPI_SPEED_8_MHz

SPI configuration.

SPI bus

◆ hV_SDK_Wire

#define hV_SDK_Wire   Wire

Wire configuration.

Wire bus

◆ SPI_SPEED_16_MHz

#define SPI_SPEED_16_MHz   16000000

SPI configuration.

SPI bus

◆ SPI_SPEED_4_MHz

#define SPI_SPEED_4_MHz   4000000

SPI speed.

Recommended 4 MHz, safe up to 8 MHz

Warning
Check hardware and other SPI connected devices

◆ SPI_SPEED_8_MHz

#define SPI_SPEED_8_MHz   8000000

SPI configuration.

SPI bus

Function Documentation

◆ hV_SDK_begin()

void hV_SDK_begin ( )

General initialisation.

hV_SDK_Serial initialised at hV_SDK_Serial_Speed

◆ hV_SDK_delayMicroseconds()

void hV_SDK_delayMicroseconds ( uint32_t us)

Microsecond non-blocking delay.

Parameters
usdelay, us

◆ hV_SDK_delayMilliseconds()

void hV_SDK_delayMilliseconds ( uint32_t ms)

Millisecond non-blocking delay.

Parameters
msdelay, ms

◆ hV_SDK_exit()

void hV_SDK_exit ( uint8_t code = 0)

General exit.

Parameters
codedefault = 0 = success, otherwise error
Note
Only used on Linux

◆ hV_SDK_getMilliseconds()

uint32_t hV_SDK_getMilliseconds ( void )

Get milliseconds since start-up.

Returns
uint32_t milliseconds since start-up
Note
Limit of 2^32 ms or ~49.7 days

◆ hV_SDK_GPIO_begin()

void hV_SDK_GPIO_begin ( void )

GPIO initialisation.

Required for GPIO expander

Warning
begin() does not initialise SPI
begin() initialises I2C

◆ hV_SDK_GPIO_define()

void hV_SDK_GPIO_define ( uint8_t pin,
uint8_t mode )

Define GPIO mode.

Parameters
pinpin number
Note
Same as hV_SDK_GPIO_pinMode(pin, mode);

◆ hV_SDK_GPIO_read()

uint8_t hV_SDK_GPIO_read ( uint8_t pin)

Read GPIO.

Parameters
pinpin number
Returns
uint8_t HIGH = true or LOW = false
Note
Synonym of hV_SDK_GPIO_get();

◆ hV_SDK_GPIO_write()

void hV_SDK_GPIO_write ( uint8_t pin,
uint8_t value )

Write GPIO.

Parameters
pinpin number
valueHIGH = true or LOW = false
Note
Synonym of hV_SDK_GPIO_set() and hV_SDK_GPIO_clear()

◆ hV_SDK_random()

uint32_t hV_SDK_random ( uint32_t maxNumber)

Pseudo-random number.

Parameters
maxNumbermaximum random number
Returns
uint32_t 0..number - 1

◆ hV_SDK_Serial_begin()

void hV_SDK_Serial_begin ( uint32_t speed = 115200)

Initialise console.

Parameters
speedin bps, eg. 115200
Deprecated
Console already initialised at 115200 by hV_SDK_begin() (6.0.7)

◆ hV_SDK_Serial_print()

template<typename T>
void hV_SDK_Serial_print ( T text)

Print to serial console.

Template Parameters
Ttype of the element, [u]int{8|16|32}_t float String char*
Parameters
textelement to print
Warning
Because of <template>, code follows definition in header file
Deprecated
Use hV_HAL_Serial_printf() and hV_HAL_Serial_crlf() instead (6.1.0)

◆ hV_SDK_Serial_printf()

void hV_SDK_Serial_printf ( const char * format,
va_list args )

Format and send to console.

Parameters
formatsee https://www.cplusplus.com/reference/cstdio/printf/ for tokens
argsexplicit variadic list required for hV_HAL_Serial_printf()

◆ hV_SDK_Serial_println()

template<typename T>
void hV_SDK_Serial_println ( T text)

Print to serial console with cr-lf at the end.

Template Parameters
Ttype of the element: [u]int{8|16|32}_t float String char*
Parameters
textelement to print
Warning
Because of <template>, code follows definition in header file
Deprecated
Use hV_HAL_Serial_printf() and hV_HAL_Serial_crlf() instead (6.1.0)

◆ hV_SDK_SPI3_define()

void hV_SDK_SPI3_define ( uint8_t pinClock = SCK,
uint8_t pinData = MOSI )

Set the 3-wire SPI pins.

Parameters
pinClockclock, default = SCK
pinDatacombined data, default = MOSI
Note
Called by hV_SDK_SPI_begin()

◆ hV_SDK_SPI3_read()

uint8_t hV_SDK_SPI3_read ( )

Read a single byte.

Returns
read byte
Note
Configure the clock pin as output and data pin as input.
Warning
/CS to be managed externally.

◆ hV_SDK_SPI3_write()

void hV_SDK_SPI3_write ( uint8_t data)

Write a single byte.

Parameters
databyte
Note
Configure the clock and data pins as output.
Warning
/CS to be managed externally.

◆ hV_SDK_SPI_begin()

void hV_SDK_SPI_begin ( uint32_t speed = 8000000)

Configure and start SPI.

Parameters
speedSPI speed in Hz, hV_HAL_SPI_SPEED = default Other values are SPI_SPEED_4_MHz, SPI_SPEED_8_MHz, SPI_SPEED_16_MHz
Note
Other parameters are
  • Bit order: MSBFIRST
  • Data mode: SPI_MODE0
Warning
SPI ESP32 uses pins SCK = 14, MISO = 12 and MOSI = 13
Note
Check for unique initialisation

◆ hV_SDK_SPI_end()

void hV_SDK_SPI_end ( )

End SPI.

Note
Check for unique deinitialisation

◆ hV_SDK_SPI_transfer() [1/2]

void hV_SDK_SPI_transfer ( uint8_t * data,
size_t size )

Combined write and read.

Parameters
dataarray of uint8_t to send
sizelength
Note
Array may be updated with read data
Warning
No check for previous initialisation

◆ hV_SDK_SPI_transfer() [2/2]

uint8_t hV_SDK_SPI_transfer ( uint8_t data)

Combined write and read of a single byte.

Parameters
databyte
Returns
read byte
Warning
No check for previous initialisation

◆ hV_SDK_Wire_begin()

void hV_SDK_Wire_begin ( )

Configure and start Wire bus.

Note
Master mode only
Check for unique initialisation

◆ hV_SDK_Wire_end()

void hV_SDK_Wire_end ( )

End Wire bus.

Note
Check for unique deinitialisation

◆ hV_SDK_Wire_transfer()

void hV_SDK_Wire_transfer ( uint8_t address,
uint8_t * dataWrite,
size_t sizeWrite,
uint8_t * dataRead = 0,
size_t sizeRead = 0 )

Combined write and read.

Parameters
[in]addressI2C device address
[in]dataWritebuffer to write
[in]sizeWritenumber of bytes
[out]dataReadbuffer to read
[in]sizeReadnumber of bytes
Note
If sizeRead = 0, no read performed
Warning
No check for previous initialisation