diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2016-02-21 21:47:40 +0200 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2016-02-21 21:47:40 +0200 |
commit | 8cbfe79dd9ce2e8113a0f99e15d6ae4d3176b545 (patch) | |
tree | 5c819c0effca1f43ae8e06d41c10328aa1f73d5b /serial_link/protocol/transport.c | |
parent | 7b88b8b7e1fd50b1fc2a219c734a3069576bcbe2 (diff) |
Add master to single slave transport
Diffstat (limited to 'serial_link/protocol/transport.c')
-rw-r--r-- | serial_link/protocol/transport.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/serial_link/protocol/transport.c b/serial_link/protocol/transport.c index e49e9d69d9..03f83a8068 100644 --- a/serial_link/protocol/transport.c +++ b/serial_link/protocol/transport.c @@ -79,6 +79,9 @@ void transport_recv_frame(uint8_t from, uint8_t* data, uint16_t size) { start = obj->buffer + LOCAL_OBJECT_SIZE(obj->object_size); start += (from - 1) * REMOTE_OBJECT_SIZE(obj->object_size); } + else { + start = obj->buffer + NUM_SLAVES * LOCAL_OBJECT_SIZE(obj->object_size); + } triple_buffer_object_t* tb = (triple_buffer_object_t*)start; void* ptr = triple_buffer_begin_write_internal(obj->object_size, tb); memcpy(ptr, data, size -1); @@ -101,5 +104,19 @@ void update_transport(void) { router_send_frame(dest, ptr, obj->object_size + 1); } } + else { + uint8_t* start = obj->buffer; + 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); + if (ptr) { + ptr[obj->object_size] = i; + uint8_t dest = j + 1; + router_send_frame(dest, ptr, obj->object_size + 1); + } + start += LOCAL_OBJECT_SIZE(obj->object_size); + } + } } } |