|
Open Model Railroad Network (OpenMRN)
|
Driver for the 74HC595 shift register. More...
#include <SN74HC595GPO.hxx>
Public Member Functions | |
| SN74HC595 (void(*request_refresh_operation)(void)) | |
| Constructor. | |
| void | init (const char *spi_name, int priority=get_priority_max()) |
| Initialize the SN74HC595 settings. | |
| void | refresh (bool from_isr=false) |
| Triggers the helper thread to wakeup and refresh the outputs. | |
Public Member Functions inherited from OSThread | |
| OSThread (const char *name, int priority, size_t stack_size, void *(*start_routine)(void *), void *arg) | |
| Create a thread. | |
| OSThread () | |
| Creates a thread via inheritance. | |
| void | start (const char *name, int priority, size_t stack_size) |
| Starts the thread. | |
| virtual | ~OSThread () |
| Default destructor. | |
| bool | is_created () |
| void | inherit () |
| Inherits the current thread. | |
| os_thread_t | get_handle () |
| void | lock_to_thread () |
| Sets the thread handle to the current calling thread's. | |
| void | unlock_from_thread () |
| Resets the thread handle to none. | |
Private Member Functions | |
| void * | entry () override |
| User entry point for the created thread. | |
| DISALLOW_COPY_AND_ASSIGN (SN74HC595) | |
Private Attributes | |
| void(* | requestRefreshOperation_ )(void) |
| Request that the GPIO cache be refreshed. | |
| int | spiFd_ |
| SPI bus that accesses the SN74HC595. | |
| OSSem | sem_ |
| semaphore for posting events | |
| uint8_t | ioPending_: 1 |
| true if an update is pending | |
| std::atomic< uint8_t > | gpoData_ [N] |
| local copy of the expansion output data | |
Static Private Attributes | |
| static constexpr uint32_t | SPI_MAX_SPEED_HZ = 4000000 |
| maximum SPI clock speed in Hz | |
Friends | |
| class | SN74HC595GPO< N > |
| Allow access to SN74HC595 from SN74HC595GPO. | |
Additional Inherited Members | |
Static Public Member Functions inherited from OSThread | |
| static int | getpriority (OSThread *thread) |
| Return the current thread priority. | |
| static int | get_priority (OSThread *thread) |
| Return the current thread priority. | |
| static int | get_priority_min () |
| Get the minimum thread priority. | |
| static int | get_priority_max () |
| Get the maximum thread priority. | |
Driver for the 74HC595 shift register.
Note: This driver makes use of std::atomic and requires an implementation of std::atomic on any platform that makes use of it. For example, at the time of creating this device driver, ARMv7-M (Cortex-M3/M4/M4F) does have support for std::atomic, while ARMv6-M (Cortex-M0) does not.
| N | number of chips on the bus, starting at 1 |
Definition at line 58 of file SN74HC595GPO.hxx.
|
inline |
Constructor.
| request_refresh_operation | This is an application specific callback for triggering a sequence of events that will result in refresh() being called. The exact implementation is application specific, and mostly is determined by whether or not these outputs must be toggled from an interrupt. |
Definition at line 67 of file SN74HC595GPO.hxx.
|
inlineoverrideprivatevirtual |
User entry point for the created thread.
Reimplemented from OSThread.
Definition at line 128 of file SN74HC595GPO.hxx.
|
inline |
Initialize the SN74HC595 settings.
Typically called in hw_postinit(), not hw_preinit() or hw_init().
| spi_name | spi interface that the SN74HC595 is on |
| priority | helper thread priority |
Definition at line 84 of file SN74HC595GPO.hxx.
Triggers the helper thread to wakeup and refresh the outputs.
| from_isr | true if called from an ISR. |
Definition at line 105 of file SN74HC595GPO.hxx.
|
friend |
Allow access to SN74HC595 from SN74HC595GPO.
Definition at line 154 of file SN74HC595GPO.hxx.
|
private |
local copy of the expansion output data
Definition at line 154 of file SN74HC595GPO.hxx.
|
private |
true if an update is pending
Definition at line 151 of file SN74HC595GPO.hxx.
|
private |
Request that the GPIO cache be refreshed.
Definition at line 147 of file SN74HC595GPO.hxx.
semaphore for posting events
Definition at line 150 of file SN74HC595GPO.hxx.
|
staticconstexprprivate |
maximum SPI clock speed in Hz
Definition at line 124 of file SN74HC595GPO.hxx.
|
private |
SPI bus that accesses the SN74HC595.
Definition at line 149 of file SN74HC595GPO.hxx.