Add shared PySetTerminal with asynchronous cancellable macros
This commit is contained in:
@@ -119,6 +119,9 @@ PCAN_ABI_API const char *pcan_abi_periph28335_command_name(
|
||||
/* PM67/TMS320F2812 legacy memory upload. */
|
||||
PCAN_ABI_API size_t pcan_abi_tms2812_build_fixed(uint8_t controller, uint8_t command,
|
||||
const uint8_t *payload, size_t payload_size, uint8_t *output, size_t output_size);
|
||||
PCAN_ABI_API int pcan_abi_tms2812_bus_step(int write, unsigned step, unsigned tetrad, unsigned reg,
|
||||
uint16_t data, uint32_t *address, uint16_t *value, uint8_t *command);
|
||||
|
||||
PCAN_ABI_API size_t pcan_abi_tms2812_build_memory(uint8_t controller, uint8_t command,
|
||||
uint32_t word_address, uint16_t value, uint8_t *output, size_t output_size);
|
||||
PCAN_ABI_API size_t pcan_abi_tms2812_build_test(uint8_t controller, uint16_t duration,
|
||||
|
||||
@@ -36,6 +36,9 @@ typedef enum {
|
||||
TMS2812_ERROR_CAPACITY = -6
|
||||
} tms2812_status_t;
|
||||
|
||||
int tms2812_bus_step(int write, unsigned step, unsigned tetrad, unsigned reg,
|
||||
uint16_t data, uint32_t *address, uint16_t *value, uint8_t *command);
|
||||
|
||||
uint16_t tms2812_crc16(const uint8_t *data, size_t size);
|
||||
|
||||
size_t tms2812_build_fixed_request(uint8_t controller, uint8_t command,
|
||||
|
||||
@@ -379,3 +379,9 @@ int pcan_abi_gui_parser_stats(const void *parser_storage, uint32_t *frames,
|
||||
if (stray_bytes != NULL) *stray_bytes = parser->stats.stray_bytes;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int pcan_abi_tms2812_bus_step(int write, unsigned step, unsigned tetrad, unsigned reg,
|
||||
uint16_t data, uint32_t *address, uint16_t *value, uint8_t *command)
|
||||
{
|
||||
return tms2812_bus_step(write, step, tetrad, reg, data, address, value, command);
|
||||
}
|
||||
|
||||
@@ -137,3 +137,16 @@ int tms2812_decode_upload_response(
|
||||
memcpy(output, &data[2], byte_count);
|
||||
return TMS2812_OK;
|
||||
}
|
||||
|
||||
int tms2812_bus_step(int write, unsigned step, unsigned tetrad, unsigned reg,
|
||||
uint16_t data, uint32_t *address, uint16_t *value, uint8_t *command)
|
||||
{
|
||||
if (!address || !value || !command) return TMS2812_ERROR_ARGUMENT;
|
||||
if ((write != 0 && write != 1) || step > 1U || tetrad > 14U || reg > 15U)
|
||||
return TMS2812_ERROR_RANGE;
|
||||
*command = (!write && step == 1U) ? TMS2812_CMD_PEEK : TMS2812_CMD_POKE;
|
||||
*address = write ? (step == 0U ? 0x200AU : 0x200BU) : (step == 0U ? 0x200BU : 0x200FU);
|
||||
*value = write && step == 0U ? data : (!write && step == 1U ? 0U :
|
||||
(uint16_t)((write ? 0x8000U : 0U) | (tetrad << 4) | reg));
|
||||
return TMS2812_OK;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,19 @@ static int test_terminal(void)
|
||||
uint8_t reply[] = {0x0a, 0x38, 0x65, 0xa5, 0, 0, 0xaf, 0x9b, 0, 0};
|
||||
const uint8_t test_prefix[] = {7, 66, 25, 0, 18, 0};
|
||||
size_t size;
|
||||
uint32_t bus_address;
|
||||
uint16_t bus_value;
|
||||
uint8_t bus_command;
|
||||
if (tms2812_bus_step(1, 0, 3, 5, 0x1234, &bus_address, &bus_value, &bus_command) ||
|
||||
bus_address != 0x200AU || bus_value != 0x1234 || bus_command != 57) return 20;
|
||||
if (tms2812_bus_step(1, 1, 3, 5, 0x1234, &bus_address, &bus_value, &bus_command) ||
|
||||
bus_address != 0x200BU || bus_value != 0x8035 || bus_command != 57) return 21;
|
||||
if (tms2812_bus_step(0, 0, 3, 5, 0, &bus_address, &bus_value, &bus_command) ||
|
||||
bus_address != 0x200BU || bus_value != 0x35 || bus_command != 57) return 22;
|
||||
if (tms2812_bus_step(0, 1, 3, 5, 0, &bus_address, &bus_value, &bus_command) ||
|
||||
bus_address != 0x200FU || bus_command != 56) return 23;
|
||||
if (tms2812_bus_step(0, 0, 15, 0, 0, &bus_address, &bus_value, &bus_command) != TMS2812_ERROR_RANGE ||
|
||||
tms2812_bus_step(0, 2, 0, 0, 0, &bus_address, &bus_value, &bus_command) != TMS2812_ERROR_RANGE) return 24;
|
||||
if (tms2812_build_memory_request(10, 0, 0, 0, output, sizeof output) != 8U ||
|
||||
memcmp(output, ping, sizeof ping) != 0) return 10;
|
||||
if (tms2812_build_memory_request(10, TMS2812_CMD_POKE, 0x12345678UL, 0xABCD,
|
||||
|
||||
Reference in New Issue
Block a user