Skip to content

Commit 6c3f01e

Browse files
committed
Added function to disable a channel (this way it can be reused later)
1 parent 23bcf16 commit 6c3f01e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Atmel TSS463C VAN bus Datalink Controller library
2-
version=1.2.0
2+
version=1.3.0
33
author=Peter Pinter <pinterpeti@gmail.com>
44
maintainer=Peter Pinter <pinterpeti@gmail.com>
55
sentence=A library for the Atmel TSS463C VAN Datalink Controller with SPI

src/tss463_van.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,19 @@ uint8_t TSS463_VAN::get_memory_address_to_use(uint8_t channelId, uint8_t message
362362
{
363363
return channels[channelId].MemoryLocation;
364364
}
365+
else
366+
{
367+
if (channels[channelId].MessageLength != 0 && channels[channelId].MessageLength <= messageLength)
368+
{
369+
return channels[channelId].MemoryLocation;
370+
}
371+
}
365372

366373
uint8_t result = next_free_memory_address;
367374
if (next_free_memory_address + messageLength <= TSS463C_RAM_SIZE_IN_BYTES - 1)
368375
{
369376
channels[channelId].MemoryLocation = next_free_memory_address;
377+
channels[channelId].MessageLength = messageLength;
370378
next_free_memory_address = next_free_memory_address + messageLength;
371379

372380
return result;

src/tss463_van.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
typedef struct ChannelSetup {
5454
uint8_t MessageLengthAndStatusRegisterValue;
5555
uint8_t MemoryLocation;
56+
uint8_t MessageLength;
5657
uint16_t Identifier;
5758
bool IsOccupied;
5859
};
@@ -83,7 +84,6 @@ class TSS463_VAN
8384
uint8_t registers_get(uint8_t address, volatile uint8_t values[], uint8_t count);
8485
void registers_set(uint8_t address, const uint8_t values[], uint8_t n);
8586
void setup_channel(uint8_t channelId, uint16_t identifier, uint8_t id1, uint8_t id2, uint8_t id2AndCommand, uint8_t messagePointer, uint8_t lengthAndStatus);
86-
void disable_channel(uint8_t channelId);
8787
uint8_t get_memory_address_to_use(uint8_t channelId, uint8_t messageLength);
8888
bool is_valid_channel(uint8_t channelId, uint16_t identifier);
8989
public:
@@ -103,6 +103,7 @@ class TSS463_VAN
103103
uint8_t get_last_channel();
104104
void set_value_in_channel(uint8_t channelId, uint8_t index0, uint8_t value);
105105
void begin();
106+
void disable_channel(uint8_t channelId);
106107
};
107108

108109
extern TSS463_VAN VAN;

0 commit comments

Comments
 (0)