34 #include "bootloader_common.h" 35 #include "bootloader/bl_peripheral.h" 36 #include "property/property.h" 49 kSerialProtocol_Version_Name =
'P',
50 kSerialProtocol_Version_Major = 1,
51 kSerialProtocol_Version_Minor = 2,
52 kSerialProtocol_Version_Bugfix = 0
58 kFramingPacketStartByte = 0x5a,
59 kFramingPacketType_Ack = 0xa1,
60 kFramingPacketType_Nak = 0xa2,
61 kFramingPacketType_AckAbort = 0xa3,
62 kFramingPacketType_Command = 0xa4,
63 kFramingPacketType_Data = 0xa5,
64 kFramingPacketType_Ping = 0xa6,
65 kFramingPacketType_PingResponse = 0xa7
71 kHostMaxStartByteReadCount = 2,
79 kIncomingPacketBufferSize = kMinPacketBufferSize,
80 kOutgoingPacketBufferSize = kMinPacketBufferSize
92 typedef struct FramingHeader
99 typedef struct FramingSyncPacket
106 typedef struct FramingDataPacket
115 typedef struct SerialFramingPacket
118 uint8_t data[kOutgoingPacketBufferSize];
122 typedef struct SerialData
124 uint8_t data[kIncomingPacketBufferSize];
137 typedef struct PingResponse
154 #if defined(__cplusplus) 156 #endif // __cplusplus 166 uint32_t *packetLength,
171 const uint8_t *packet,
196 #if defined(BOOTLOADER_HOST) 197 void host_delay(uint32_t milliseconds);
198 #endif // BOOTLOADER_HOST 200 #if defined(__cplusplus) 202 #endif // __cplusplus uint32_t serial_packet_get_max_packet_size(const peripheral_descriptor_t *self)
Get max packet size.
Definition: serial_packet.c:265
void serial_packet_abort(const peripheral_descriptor_t *self)
Abort data phase.
Definition: serial_packet.c:257
uint16_t length
Number of data bytes that follow.
Definition: serial_packet.h:109
_framing_packet_constants
Serial framing packet constants.
Definition: serial_packet.h:56
uint32_t readOffset
The offset into the buffer that the app has read out.
Definition: serial_packet.h:128
standard_version_t version
Serial framing protocol version.
Definition: serial_packet.h:139
packet_type_t
Packet types.
Definition: bl_peripheral.h:94
status_t serial_packet_read(const peripheral_descriptor_t *self, uint8_t **packet, uint32_t *packetLength, packet_type_t packetType)
Read packet using serial framing.
Definition: serial_packet.c:129
uint8_t packetType
Framing packet type.
Definition: serial_packet.h:95
bool isAckNeeded
True if need to send ACK to previously received packet.
Definition: serial_packet.h:129
Size for callback buffer, Must be power of 2 for easy wrap.
Definition: serial_packet.h:73
_timing_constants
Timeout and other constants.
Definition: serial_packet.h:69
framing_data_packet_t dataPacket
Packet header.
Definition: serial_packet.h:117
status_t serial_send_ping_response(const peripheral_descriptor_t *peripheral)
Send a ping message back in response to a ping.
Definition: serial_packet.c:335
status_t serial_packet_init(const peripheral_descriptor_t *self)
Initialize component.
Definition: serial_packet.c:117
volatile uint32_t writeOffset
The offset into the buffer that the ISR will queue data into.
Definition: serial_packet.h:127
Serial framing data packet.
Definition: serial_packet.h:106
Peripheral Packet Interface.
Definition: bl_peripheral.h:101
_serial_packet_constants
Incoming data buffer allocation size.
Definition: serial_packet.h:77
bool isAckAbortNeeded
True if next ACK should be ACK Abort.
Definition: serial_packet.h:131
serial_framing_packet_t framingPacket
Buffer for outgoing packet.
Definition: serial_packet.h:126
void serial_packet_queue_byte(uint8_t byte)
Queues a byte received by the active peripheral.
Definition: serial_packet.c:110
Structure of version property.
Definition: bootloader_common.h:168
_serial_packet_mode
Packet state machine modes.
Definition: serial_packet.h:84
status_t serial_packet_send_sync(uint8_t framingPacketType)
Send a sync packet of the specified type.
Definition: serial_packet.c:271
_serial_protocol_version_constants
Version constants for serial framing protocol.
Definition: serial_packet.h:47
Format of global context data.
Definition: serial_packet.h:122
uint16_t options
Serial framing protocol options bitfield.
Definition: serial_packet.h:140
uint8_t startByte
#kFramingPacketStartByte
Definition: serial_packet.h:94
bool isBackToBackWrite
True if executing back-to-back write.
Definition: serial_packet.h:130
status_t serial_packet_write(const peripheral_descriptor_t *self, const uint8_t *packet, uint32_t byteCount, packet_type_t packetType)
Write packet using serial framing.
Definition: serial_packet.c:195
Serial ping response format.
Definition: serial_packet.h:137
Serial framing sync packet.
Definition: serial_packet.h:99
status_t serial_packet_finalize(const peripheral_descriptor_t *self)
Finalize.
Definition: serial_packet.c:123
Framing packet with data area.
Definition: serial_packet.h:115
uint16_t crc16
CRC-16 of data packet header and data.
Definition: serial_packet.h:110
Default value for receiving 1 byte timeout.
Definition: serial_packet.h:72
framing_header_t header
Framing packet header.
Definition: serial_packet.h:101
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:121