36#ifndef _FREERTOS_DRIVERS_COMMON_SN74HC595GPO_HXX_
37#define _FREERTOS_DRIVERS_COMMON_SN74HC595GPO_HXX_
74 for (
unsigned i = 0; i < N; ++i)
86 spiFd_ = ::open(spi_name, O_WRONLY);
90 uint8_t spi_mode = SPI_MODE_0;
100 start(
"SN74HC595", priority, 384 + N);
113 sem_.post_from_isr(&woken);
137 for (
unsigned i = 0; i < N; ++i)
188 new_state ?
set() :
clr();
196 Gpio::SET : Gpio::CLR;
223 HASSERT(dir == Gpio::Direction::DOUTPUT);
230 return Gpio::Direction::DOUTPUT;
int ioctl(int fd, unsigned long int key,...)
Request and ioctl transaction.
OS-independent abstraction for GPIO.
Value
Defines the options for GPIO level.
Direction
Defines the options for GPIO direction.
This class provides a counting semaphore API.
void post()
Post (increment) a semaphore.
void wait()
Wait on (decrement) a semaphore.
This class provides a threading API.
static int get_priority_max()
Get the maximum thread priority.
void start(const char *name, int priority, size_t stack_size)
Starts the thread.
General Purpose Output (GPO) instance on the 74HC595.
Value read() const override
Retrieves the current Value of a GPO output sate (requested).
void set_direction(Gpio::Direction dir) const override
Sets the GPO direction (does nothing).
const uint8_t bit_
bit number representative of the bit
const uint8_t chipIndex_
index on the bus for the chip
void set() const override
Sets the GPO pin to high.
void write(Value new_state) const override
Writes a GPO pin (set or clear to a specific state).
Direction direction() const override
Gets the GPO direction.
constexpr SN74HC595GPO(SN74HC595< N > *instance, uint8_t chip_index, uint8_t bit)
Constructor.
void clr() const override
Clears the GPO pin to low.
SN74HC595< N > *const instance_
reference to chip instance
Driver for the 74HC595 shift register.
OSSem sem_
semaphore for posting events
void init(const char *spi_name, int priority=get_priority_max())
Initialize the SN74HC595 settings.
SN74HC595(void(*request_refresh_operation)(void))
Constructor.
int spiFd_
SPI bus that accesses the SN74HC595.
void refresh(bool from_isr=false)
Triggers the helper thread to wakeup and refresh the outputs.
void * entry() override
User entry point for the created thread.
static constexpr uint32_t SPI_MAX_SPEED_HZ
maximum SPI clock speed in Hz
uint8_t ioPending_
true if an update is pending
void(* requestRefreshOperation_)(void)
Request that the GPIO cache be refreshed.
std::atomic< uint8_t > gpoData_[N]
local copy of the expansion output data
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.