Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MBED_LIN_RGB_Master_Example
Diff: LinMaster.h
- Revision:
- 8:63d341e53cce
- Parent:
- 7:53b2cded83f3
--- a/LinMaster.h Mon Jun 08 11:59:35 2020 +0000
+++ b/LinMaster.h Mon Jun 15 12:42:04 2020 +0000
@@ -22,11 +22,11 @@
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-
-#include "mbed.h"
#ifndef MBED_LIN_MASTER_H
#define MBED_LIN_MASTER_H
+
+#include "mbed.h"
/** A master device LIN communication library for mbed
*
@@ -88,7 +88,7 @@
* The current configured LIN baudrate
*/
uint16_t baudrate(void);
-
+
/** Bus status */
enum DriverStatus_t {
INIT, /**< initializing */
@@ -128,19 +128,19 @@
S2M,
M2S
};
-
+
/** CRC Type */
enum CrcType_t {
Classic,
Enhanced
};
-
+
/** Brake Type */
enum BrakeType_t {
Normal,
AutoConfig
};
-
+
/** Frame */
struct Frame_t {
FrameType_t FrameType;
@@ -150,7 +150,7 @@
uint8_t FrameID;
uint8_t Data[8];
};
-
+
/** Send a frame on the LIN bus
*
* @param ptrFrame pointer to the frame to transmit
@@ -159,7 +159,7 @@
* false on fail
*/
bool send_frame(Frame_t * ptrFrame);
-
+
/** Receive a frame on the LIN bus
*
* @param ptrFrame pointer to the frame to receive
@@ -168,9 +168,11 @@
* false on fail
*/
bool get_rx_data(Frame_t & ptrFrame);
-
+
void TickEventHndl(void);
-
+
+ void RXtimeoutEventHndl(void);
+
void PinEventHndl(void);
private:
@@ -189,7 +191,7 @@
Data7,
CRC
};
-
+
enum ByteStatus_t {
BStart,
StartbitEdge, /* Begin of startbit received */
@@ -223,21 +225,19 @@
uint8_t breakLength;
uint8_t FrameLength;
-
+
uint8_t TXbuf[11];
uint8_t TXbufIndex;
uint8_t RXbuf[11];
uint8_t RXbufIndex;
- uint8_t RXtimeout;
- uint16_t RXtimeoutSubCTR;
- uint16_t u16HalfBitPeriod;
+ std::chrono::microseconds u16HalfBitPeriod;
- DigitalOut LinOutPin;
- DigitalIn LinInPin;
- InterruptIn LinIntPin;
- Ticker MyTicker;
- Timer MyTimer;
-
+ DigitalOut LinOutPin;
+ InterruptIn LinInPin;
+ std::chrono::microseconds FrameTimeout;
+ Ticker HalfbitTicker;
+ Ticker TimeoutTicker;
+
uint8_t parity(uint8_t u8BYTE);
};