Remove some warnings, change the include paths.
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-INC += $(SERIAL_DIR)
\ No newline at end of file
+INC += $(SERIAL_DIR)
+SRC += $(wildcard $(SERIAL_DIR)/serial_link/protocol/*.c)
\ No newline at end of file
SOFTWARE.
*/
-#include "protocol/byte_stuffer.h"
-#include "protocol/frame_validator.h"
-#include "protocol/physical.h"
-#include <stdio.h>
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/physical.h"
+#include <stdbool.h>
// This implements the "Consistent overhead byte stuffing protocol"
// https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing
SOFTWARE.
*/
+#ifndef SERIAL_LINK_BYTE_STUFFER_H
+#define SERIAL_LINK_BYTE_STUFFER_H
+
+#include <stdint.h>
+
void init_byte_stuffer(void);
void byte_stuffer_recv_byte(uint8_t link, uint8_t data);
void byte_stuffer_send_frame(uint8_t link, uint8_t* data, uint16_t size);
+
+#endif
SOFTWARE.
*/
-#include "protocol/frame_router.h"
-#include "protocol/transport.h"
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/frame_validator.h"
static bool is_master;
SOFTWARE.
*/
+#ifndef SERIAL_LINK_FRAME_ROUTER_H
+#define SERIAL_LINK_FRAME_ROUTER_H
+
+#include <stdint.h>
+#include <stdbool.h>
+
#define UP_LINK 0
#define DOWN_LINK 1
void router_set_master(bool master);
void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size);
void router_send_frame(uint8_t destination, uint8_t* data, uint16_t size);
+
+#endif
SOFTWARE.
*/
-#include "protocol/frame_validator.h"
-#include "protocol/frame_router.h"
-#include "protocol/byte_stuffer.h"
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/byte_stuffer.h"
+#include <string.h>
const uint32_t poly8_lookup[256] =
{
SOFTWARE.
*/
+#ifndef SERIAL_LINK_FRAME_VALIDATOR_H
+#define SERIAL_LINK_FRAME_VALIDATOR_H
+
+#include <stdint.h>
+
void validator_recv_frame(uint8_t link, uint8_t* data, uint16_t size);
// The buffer pointed to by the data needs 4 additional bytes
void validator_send_frame(uint8_t link, uint8_t* data, uint16_t size);
+
+#endif
SOFTWARE.
*/
+#ifndef SERIAL_LINK_PHYSICAL_H
+#define SERIAL_LINK_PHYSICAL_H
+
void send_data(uint8_t link, const uint8_t* data, uint16_t size);
+
+#endif
SOFTWARE.
*/
-#include "protocol/transport.h"
-#include "protocol/frame_router.h"
-#include "protocol/triple_buffered_object.h"
+#include "serial_link/protocol/transport.h"
+#include "serial_link/protocol/frame_router.h"
+#include "serial_link/protocol/triple_buffered_object.h"
+#include <string.h>
static remote_object_t** remote_objects;
static uint32_t num_remote_objects;
void init_transport(remote_object_t** _remote_objects, uint32_t _num_remote_objects) {
remote_objects = _remote_objects;
num_remote_objects = _num_remote_objects;
- int i;
+ unsigned int i;
for(i=0;i<num_remote_objects;i++) {
remote_object_t* obj = remote_objects[i];
if (obj->object_type == MASTER_TO_ALL_SLAVES) {
}
else if(obj->object_type == MASTER_TO_SINGLE_SLAVE) {
uint8_t* start = obj->buffer;
- int j;
+ unsigned int j;
for (j=0;j<NUM_SLAVES;j++) {
triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
start += LOCAL_OBJECT_SIZE(obj->object_size);
- int j;
+ unsigned int j;
for (j=0;j<NUM_SLAVES;j++) {
tb = (triple_buffer_object_t*)start;
triple_buffer_init(tb);
triple_buffer_end_write_internal(tb);
}
-uint32_t transport_send_frame(uint8_t to, uint8_t* data, uint16_t size) {
-}
-
void update_transport(void) {
- int i;
+ unsigned int i;
for(i=0;i<num_remote_objects;i++) {
remote_object_t* obj = remote_objects[i];
if (obj->object_type == MASTER_TO_ALL_SLAVES || obj->object_type == SLAVE_TO_MASTER) {
}
else {
uint8_t* start = obj->buffer;
- int j;
+ unsigned int j;
for (j=0;j<NUM_SLAVES;j++) {
triple_buffer_object_t* tb = (triple_buffer_object_t*)start;
uint8_t* ptr = (uint8_t*)triple_buffer_read_internal(obj->object_size + LOCAL_OBJECT_EXTRA, tb);
#ifndef SERIAL_LINK_TRANSPORT_H
#define SERIAL_LINK_TRANSPORT_H
-#include "protocol/triple_buffered_object.h"
-#include "system/system.h"
+#include "serial_link/protocol/triple_buffered_object.h"
+#include "serial_link/system/system.h"
#define NUM_SLAVES 8
#define LOCAL_OBJECT_EXTRA 16
void init_transport(remote_object_t** remote_objects, uint32_t num_remote_objects);
void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size);
-uint32_t transport_send_frame(uint8_t to, uint8_t* data, uint16_t size);
void update_transport(void);
#endif
SOFTWARE.
*/
-#include "protocol/triple_buffered_object.h"
-#include "system/system.h"
+#include "serial_link/protocol/triple_buffered_object.h"
+#include "serial_link/system/system.h"
+#include <stdbool.h>
+#include <stddef.h>
#define GET_READ_INDEX() object->state & 3
#define GET_WRITE_INDEX() (object->state >> 2) & 3
#ifndef SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H
#define SERIAL_LINK_TRIPLE_BUFFERED_OBJECT_H
+#include <stdint.h>
+
typedef struct {
uint8_t state;
uint8_t buffer[] __attribute__((aligned(4)));
#ifndef SERIAL_LINK_SYSTEM_H
#define SERIAL_LINK_SYSTEM_H
-void serial_link_lock() {
+inline void serial_link_lock(void) {
}
-void serial_link_unlock() {
+inline void serial_link_unlock(void) {
}
-void signal_data_written(void);
+void singal_data_written(void);
+
+#if defined(PROTOCOL_CHIBIOS)
+
+inline void signal_data_written(void) {
+}
+#endif
#endif
CC = gcc
CFLAGS =
-INCLUDES = -I. -I../
+INCLUDES = -I. -I../../
LDFLAGS = -L$(BUILDDIR)/cgreen/build-c/src -shared
LDLIBS = -lcgreen
UNITOBJ = $(BUILDDIR)/serialtest/unitobj
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
-#include "protocol/byte_stuffer.h"
-#include "protocol/byte_stuffer.c"
-#include "protocol/frame_validator.h"
-#include "protocol/physical.h"
+#include "serial_link/protocol/byte_stuffer.h"
+#include "serial_link/protocol/byte_stuffer.c"
+#include "serial_link/protocol/frame_validator.h"
+#include "serial_link/protocol/physical.h"
static uint8_t sent_data[MAX_FRAME_SIZE*2];
static uint16_t sent_data_size;
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
-#include "protocol/byte_stuffer.c"
-#include "protocol/frame_validator.c"
-#include "protocol/frame_router.c"
-#include "protocol/transport.h"
+#include "serial_link/protocol/byte_stuffer.c"
+#include "serial_link/protocol/frame_validator.c"
+#include "serial_link/protocol/frame_router.c"
+#include "serial_link/protocol/transport.h"
static uint8_t received_data[256];
static uint16_t received_data_size;
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
-#include "protocol/frame_validator.c"
+#include "serial_link/protocol/frame_validator.c"
void route_incoming_frame(uint8_t link, uint8_t* data, uint16_t size) {
mock(data, size);
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
-#include "protocol/transport.c"
-#include "protocol/triple_buffered_object.c"
+#include "serial_link/protocol/transport.c"
+#include "serial_link/protocol/triple_buffered_object.c"
void signal_data_written(void) {
mock();
*/
#include <cgreen/cgreen.h>
-#include "protocol/triple_buffered_object.c"
+#include "serial_link/protocol/triple_buffered_object.c"
typedef struct {
uint8_t state;