diff options
author | Jakob Odersky <jodersky@gmail.com> | 2013-02-26 16:44:22 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2013-02-26 16:44:22 +0100 |
commit | e8e5650006961593559b57176c4d2916b5c32d4e (patch) | |
tree | 4d93ffef4ba1439cec0b3f15928963ddd88cc6e7 /c/arduino/arq.h | |
parent | a9ef6d2ce9ab5f8f7d5d7993fa281f89e756d09a (diff) | |
download | ace-e8e5650006961593559b57176c4d2916b5c32d4e.tar.gz ace-e8e5650006961593559b57176c4d2916b5c32d4e.tar.bz2 ace-e8e5650006961593559b57176c4d2916b5c32d4e.zip |
restructure c implementation directory
Diffstat (limited to 'c/arduino/arq.h')
-rw-r--r-- | c/arduino/arq.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/c/arduino/arq.h b/c/arduino/arq.h new file mode 100644 index 0000000..592b0d4 --- /dev/null +++ b/c/arduino/arq.h @@ -0,0 +1,52 @@ +#ifndef ARQ_H +#define ARQ_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdbool.h> +#include <inttypes.h> + +#include "framing.h" + + +typedef enum { + RECEIVED = 0, + SEND_SUCCESS = 1, + NO_ACK = 3, + BAD_ACK = 4, + SIZE_ERROR = 5, + BUSY = 6 +} message_event; + +typedef void (*send_frame_function)(int16_t size, uint8_t* data); +typedef void (*message_event_function)(message_event e, int16_t size, const uint8_t* const message); +typedef void (*void_function)(); + +typedef struct { + uint8_t last_sent_buffer[MAX_FRAME_SIZE]; + int16_t last_sent_size; + uint8_t last_received_seq; + uint8_t resends; + bool awaiting_ack; + + send_frame_function sender; + message_event_function event_handler; + void_function start_timer; + void_function stop_timer; + +} arq; + +void init_arq(arq* a); +void receive_frame(arq* a, int16_t size, uint8_t* data); +void timeout(arq* a); +void send_message(arq* a, int16_t size, const uint8_t * const message); + + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* ARQ_H */ |