eRPC API Reference  Rev. 1.12.0
NXP Semiconductors
erpc_spi_slave_transport.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2021 NXP
4  * All rights reserved.
5  *
6  *
7  * SPDX-License-Identifier: BSD-3-Clause
8  */
9 
10 #ifndef _EMBEDDED_RPC__SPI_SLAVE_TRANSPORT_H_
11 #define _EMBEDDED_RPC__SPI_SLAVE_TRANSPORT_H_
12 
13 #include "erpc_config_internal.h"
14 #include <cstdlib>
15 #if ERPC_THREADS
16 #include "erpc_threading.h"
17 #endif
19 
20 extern "C" {
21 #include "fsl_gpio.h"
22 #include "fsl_spi.h"
23 }
24 
31 // Classes
34 
35 namespace erpc {
42 {
43 public:
51  SpiSlaveTransport(SPI_Type *spiBaseAddr, uint32_t baudRate, uint32_t srcClock_Hz);
52 
56  virtual ~SpiSlaveTransport(void);
57 
63  virtual erpc_status_t init(void);
64 
70  void transfer_cb(void);
71 
72 protected:
73  SPI_Type *m_spiBaseAddr;
74  uint32_t m_baudRate;
75  uint32_t m_srcClock_Hz;
76  bool m_isInited;
77 #if ERPC_THREADS
79 #endif
80 
81 private:
84 
94  virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) override;
95 
105  virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) override;
106 };
107 
108 } // namespace erpc
109 
112 #endif // _EMBEDDED_RPC__SPI_SLAVE_TRANSPORT_H_
bool m_isInited
Definition: erpc_spi_slave_transport.hpp:76
Base class for framed transport layers.
Definition: erpc_framed_transport.hpp:56
uint32_t m_srcClock_Hz
Definition: erpc_spi_slave_transport.hpp:75
enum _erpc_status erpc_status_t
Type used for all status and error return values.
Definition: erpc_common.h:85
void transfer_cb(void)
Function called from SPI_SlaveUserCallback when SPI transfer is completed.
Definition: erpc_spi_slave_transport.cpp:94
Semaphore m_txrxSemaphore
Definition: erpc_spi_slave_transport.hpp:78
virtual erpc_status_t underlyingReceive(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when receiving data.
Definition: erpc_framed_transport.cpp:177
Very basic transport to send/receive messages via SPI.
Definition: erpc_spi_slave_transport.hpp:41
Definition: erpc_arbitrated_client_manager.hpp:25
SPI_Type * m_spiBaseAddr
Definition: erpc_spi_slave_transport.hpp:73
virtual erpc_status_t init(void)
Initialize SPI peripheral configuration structure with values specified in SpiTransport constructor...
Definition: erpc_spi_slave_transport.cpp:137
virtual ~SpiSlaveTransport(void)
Destructor.
Definition: erpc_spi_slave_transport.cpp:125
virtual erpc_status_t underlyingSend(MessageBuffer *message, uint32_t size, uint32_t offset)
Adds ability to framed transport to overwrite MessageBuffer when sending data.
Definition: erpc_framed_transport.cpp:170
SpiSlaveTransport(SPI_Type *spiBaseAddr, uint32_t baudRate, uint32_t srcClock_Hz)
Constructor.
Definition: erpc_spi_slave_transport.cpp:115
uint32_t m_baudRate
Definition: erpc_spi_slave_transport.hpp:74
Simple semaphore class.
Definition: erpc_threading.h:442