diff options
Diffstat (limited to 'drivers')
29 files changed, 5916 insertions, 261 deletions
diff --git a/drivers/avr/i2c_master.c b/drivers/avr/i2c_master.c index b1e488529..2773e0077 100644 --- a/drivers/avr/i2c_master.c +++ b/drivers/avr/i2c_master.c | |||
@@ -28,8 +28,14 @@ | |||
28 | # define F_SCL 400000UL // SCL frequency | 28 | # define F_SCL 400000UL // SCL frequency |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifndef I2C_START_RETRY_COUNT | ||
32 | # define I2C_START_RETRY_COUNT 20 | ||
33 | #endif // I2C_START_RETRY_COUNT | ||
34 | |||
31 | #define TWBR_val (((F_CPU / F_SCL) - 16) / 2) | 35 | #define TWBR_val (((F_CPU / F_SCL) - 16) / 2) |
32 | 36 | ||
37 | #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) | ||
38 | |||
33 | void i2c_init(void) { | 39 | void i2c_init(void) { |
34 | TWSR = 0; /* no prescaler */ | 40 | TWSR = 0; /* no prescaler */ |
35 | TWBR = (uint8_t)TWBR_val; | 41 | TWBR = (uint8_t)TWBR_val; |
@@ -47,7 +53,7 @@ void i2c_init(void) { | |||
47 | #endif | 53 | #endif |
48 | } | 54 | } |
49 | 55 | ||
50 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | 56 | static i2c_status_t i2c_start_impl(uint8_t address, uint16_t timeout) { |
51 | // reset TWI control register | 57 | // reset TWI control register |
52 | TWCR = 0; | 58 | TWCR = 0; |
53 | // transmit START condition | 59 | // transmit START condition |
@@ -86,6 +92,17 @@ i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | |||
86 | return I2C_STATUS_SUCCESS; | 92 | return I2C_STATUS_SUCCESS; |
87 | } | 93 | } |
88 | 94 | ||
95 | i2c_status_t i2c_start(uint8_t address, uint16_t timeout) { | ||
96 | // Retry i2c_start_impl a bunch times in case the remote side has interrupts disabled. | ||
97 | uint16_t timeout_timer = timer_read(); | ||
98 | uint16_t time_slice = MAX(1, (timeout == (I2C_TIMEOUT_INFINITE)) ? 5 : (timeout / (I2C_START_RETRY_COUNT))); // if it's infinite, wait 1ms between attempts, otherwise split up the entire timeout into the number of retries | ||
99 | i2c_status_t status; | ||
100 | do { | ||
101 | status = i2c_start_impl(address, time_slice); | ||
102 | } while ((status < 0) && ((timeout == I2C_TIMEOUT_INFINITE) || (timer_elapsed(timeout_timer) < timeout))); | ||
103 | return status; | ||
104 | } | ||
105 | |||
89 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) { | 106 | i2c_status_t i2c_write(uint8_t data, uint16_t timeout) { |
90 | // load data into data register | 107 | // load data into data register |
91 | TWDR = data; | 108 | TWDR = data; |
diff --git a/drivers/avr/i2c_slave.c b/drivers/avr/i2c_slave.c index 62a378165..2907f164c 100644 --- a/drivers/avr/i2c_slave.c +++ b/drivers/avr/i2c_slave.c | |||
@@ -17,6 +17,7 @@ | |||
17 | * GitHub repository: https://github.com/g4lvanix/I2C-slave-lib | 17 | * GitHub repository: https://github.com/g4lvanix/I2C-slave-lib |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <stddef.h> | ||
20 | #include <avr/io.h> | 21 | #include <avr/io.h> |
21 | #include <util/twi.h> | 22 | #include <util/twi.h> |
22 | #include <avr/interrupt.h> | 23 | #include <avr/interrupt.h> |
@@ -24,6 +25,12 @@ | |||
24 | 25 | ||
25 | #include "i2c_slave.h" | 26 | #include "i2c_slave.h" |
26 | 27 | ||
28 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
29 | # include "transactions.h" | ||
30 | |||
31 | static volatile bool is_callback_executor = false; | ||
32 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
33 | |||
27 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; | 34 | volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; |
28 | 35 | ||
29 | static volatile uint8_t buffer_address; | 36 | static volatile uint8_t buffer_address; |
@@ -48,11 +55,14 @@ ISR(TWI_vect) { | |||
48 | case TW_SR_SLA_ACK: | 55 | case TW_SR_SLA_ACK: |
49 | // The device is now a slave receiver | 56 | // The device is now a slave receiver |
50 | slave_has_register_set = false; | 57 | slave_has_register_set = false; |
58 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
59 | is_callback_executor = false; | ||
60 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
51 | break; | 61 | break; |
52 | 62 | ||
53 | case TW_SR_DATA_ACK: | 63 | case TW_SR_DATA_ACK: |
54 | // This device is a slave receiver and has received data | 64 | // This device is a slave receiver and has received data |
55 | // First byte is the location then the bytes will be writen in buffer with auto-incriment | 65 | // First byte is the location then the bytes will be writen in buffer with auto-increment |
56 | if (!slave_has_register_set) { | 66 | if (!slave_has_register_set) { |
57 | buffer_address = TWDR; | 67 | buffer_address = TWDR; |
58 | 68 | ||
@@ -60,10 +70,25 @@ ISR(TWI_vect) { | |||
60 | ack = 0; | 70 | ack = 0; |
61 | buffer_address = 0; | 71 | buffer_address = 0; |
62 | } | 72 | } |
63 | slave_has_register_set = true; // address has been receaved now fill in buffer | 73 | slave_has_register_set = true; // address has been received now fill in buffer |
74 | |||
75 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
76 | // Work out if we're attempting to execute a callback | ||
77 | is_callback_executor = buffer_address == split_transaction_table[I2C_EXECUTE_CALLBACK].initiator2target_offset; | ||
78 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
64 | } else { | 79 | } else { |
65 | i2c_slave_reg[buffer_address] = TWDR; | 80 | i2c_slave_reg[buffer_address] = TWDR; |
66 | buffer_address++; | 81 | buffer_address++; |
82 | |||
83 | #if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
84 | // If we're intending to execute a transaction callback, do so, as we've just received the transaction ID | ||
85 | if (is_callback_executor) { | ||
86 | split_transaction_desc_t *trans = &split_transaction_table[split_shmem->transaction_id]; | ||
87 | if (trans->slave_callback) { | ||
88 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); | ||
89 | } | ||
90 | } | ||
91 | #endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
67 | } | 92 | } |
68 | break; | 93 | break; |
69 | 94 | ||
diff --git a/drivers/avr/i2c_slave.h b/drivers/avr/i2c_slave.h index 1cd0625ef..a8647c9da 100644 --- a/drivers/avr/i2c_slave.h +++ b/drivers/avr/i2c_slave.h | |||
@@ -22,7 +22,18 @@ | |||
22 | 22 | ||
23 | #pragma once | 23 | #pragma once |
24 | 24 | ||
25 | #define I2C_SLAVE_REG_COUNT 30 | 25 | #ifndef I2C_SLAVE_REG_COUNT |
26 | |||
27 | # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
28 | # include "transport.h" | ||
29 | # define I2C_SLAVE_REG_COUNT sizeof(split_shared_memory_t) | ||
30 | # else // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
31 | # define I2C_SLAVE_REG_COUNT 30 | ||
32 | # endif // defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) | ||
33 | |||
34 | #endif // I2C_SLAVE_REG_COUNT | ||
35 | |||
36 | _Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); | ||
26 | 37 | ||
27 | extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; | 38 | extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; |
28 | 39 | ||
diff --git a/drivers/avr/serial.c b/drivers/avr/serial.c index 3647bee0d..9a7345a53 100644 --- a/drivers/avr/serial.c +++ b/drivers/avr/serial.c | |||
@@ -224,15 +224,8 @@ | |||
224 | # define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY / 2) | 224 | # define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY / 2) |
225 | 225 | ||
226 | # define SLAVE_INT_WIDTH_US 1 | 226 | # define SLAVE_INT_WIDTH_US 1 |
227 | # ifndef SERIAL_USE_MULTI_TRANSACTION | 227 | # define SLAVE_INT_ACK_WIDTH_UNIT 2 |
228 | # define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY | 228 | # define SLAVE_INT_ACK_WIDTH 4 |
229 | # else | ||
230 | # define SLAVE_INT_ACK_WIDTH_UNIT 2 | ||
231 | # define SLAVE_INT_ACK_WIDTH 4 | ||
232 | # endif | ||
233 | |||
234 | static SSTD_t *Transaction_table = NULL; | ||
235 | static uint8_t Transaction_table_size = 0; | ||
236 | 229 | ||
237 | inline static void serial_delay(void) ALWAYS_INLINE; | 230 | inline static void serial_delay(void) ALWAYS_INLINE; |
238 | inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); } | 231 | inline static void serial_delay(void) { _delay_us(SERIAL_DELAY); } |
@@ -259,16 +252,12 @@ inline static void serial_low(void) { writePinLow(SOFT_SERIAL_PIN); } | |||
259 | inline static void serial_high(void) ALWAYS_INLINE; | 252 | inline static void serial_high(void) ALWAYS_INLINE; |
260 | inline static void serial_high(void) { writePinHigh(SOFT_SERIAL_PIN); } | 253 | inline static void serial_high(void) { writePinHigh(SOFT_SERIAL_PIN); } |
261 | 254 | ||
262 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) { | 255 | void soft_serial_initiator_init(void) { |
263 | Transaction_table = sstd_table; | ||
264 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
265 | serial_output(); | 256 | serial_output(); |
266 | serial_high(); | 257 | serial_high(); |
267 | } | 258 | } |
268 | 259 | ||
269 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) { | 260 | void soft_serial_target_init(void) { |
270 | Transaction_table = sstd_table; | ||
271 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
272 | serial_input_with_pullup(); | 261 | serial_input_with_pullup(); |
273 | 262 | ||
274 | // Enable INT0-INT7 | 263 | // Enable INT0-INT7 |
@@ -395,19 +384,14 @@ static inline uint8_t nibble_bits_count(uint8_t bits) { | |||
395 | 384 | ||
396 | // interrupt handle to be used by the target device | 385 | // interrupt handle to be used by the target device |
397 | ISR(SERIAL_PIN_INTERRUPT) { | 386 | ISR(SERIAL_PIN_INTERRUPT) { |
398 | # ifndef SERIAL_USE_MULTI_TRANSACTION | ||
399 | serial_low(); | ||
400 | serial_output(); | ||
401 | SSTD_t *trans = Transaction_table; | ||
402 | # else | ||
403 | // recive transaction table index | 387 | // recive transaction table index |
404 | uint8_t tid, bits; | 388 | uint8_t tid, bits; |
405 | uint8_t pecount = 0; | 389 | uint8_t pecount = 0; |
406 | sync_recv(); | 390 | sync_recv(); |
407 | bits = serial_read_chunk(&pecount, 7); | 391 | bits = serial_read_chunk(&pecount, 8); |
408 | tid = bits >> 3; | 392 | tid = bits >> 3; |
409 | bits = (bits & 7) != nibble_bits_count(tid); | 393 | bits = (bits & 7) != (nibble_bits_count(tid) & 7); |
410 | if (bits || pecount > 0 || tid > Transaction_table_size) { | 394 | if (bits || pecount > 0 || tid > NUM_TOTAL_TRANSACTIONS) { |
411 | return; | 395 | return; |
412 | } | 396 | } |
413 | serial_delay_half1(); | 397 | serial_delay_half1(); |
@@ -415,18 +399,22 @@ ISR(SERIAL_PIN_INTERRUPT) { | |||
415 | serial_high(); // response step1 low->high | 399 | serial_high(); // response step1 low->high |
416 | serial_output(); | 400 | serial_output(); |
417 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT * SLAVE_INT_ACK_WIDTH); | 401 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT * SLAVE_INT_ACK_WIDTH); |
418 | SSTD_t *trans = &Transaction_table[tid]; | 402 | split_transaction_desc_t *trans = &split_transaction_table[tid]; |
419 | serial_low(); // response step2 ack high->low | 403 | serial_low(); // response step2 ack high->low |
420 | # endif | 404 | |
405 | // If the transaction has a callback, we can execute it now | ||
406 | if (trans->slave_callback) { | ||
407 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); | ||
408 | } | ||
421 | 409 | ||
422 | // target send phase | 410 | // target send phase |
423 | if (trans->target2initiator_buffer_size > 0) serial_send_packet((uint8_t *)trans->target2initiator_buffer, trans->target2initiator_buffer_size); | 411 | if (trans->target2initiator_buffer_size > 0) serial_send_packet((uint8_t *)split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size); |
424 | // target switch to input | 412 | // target switch to input |
425 | change_sender2reciver(); | 413 | change_sender2reciver(); |
426 | 414 | ||
427 | // target recive phase | 415 | // target recive phase |
428 | if (trans->initiator2target_buffer_size > 0) { | 416 | if (trans->initiator2target_buffer_size > 0) { |
429 | if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer, trans->initiator2target_buffer_size)) { | 417 | if (serial_recive_packet((uint8_t *)split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size)) { |
430 | *trans->status = TRANSACTION_ACCEPTED; | 418 | *trans->status = TRANSACTION_ACCEPTED; |
431 | } else { | 419 | } else { |
432 | *trans->status = TRANSACTION_DATA_ERROR; | 420 | *trans->status = TRANSACTION_DATA_ERROR; |
@@ -448,14 +436,12 @@ ISR(SERIAL_PIN_INTERRUPT) { | |||
448 | // TRANSACTION_NO_RESPONSE | 436 | // TRANSACTION_NO_RESPONSE |
449 | // TRANSACTION_DATA_ERROR | 437 | // TRANSACTION_DATA_ERROR |
450 | // this code is very time dependent, so we need to disable interrupts | 438 | // this code is very time dependent, so we need to disable interrupts |
451 | # ifndef SERIAL_USE_MULTI_TRANSACTION | ||
452 | int soft_serial_transaction(void) { | ||
453 | SSTD_t *trans = Transaction_table; | ||
454 | # else | ||
455 | int soft_serial_transaction(int sstd_index) { | 439 | int soft_serial_transaction(int sstd_index) { |
456 | if (sstd_index > Transaction_table_size) return TRANSACTION_TYPE_ERROR; | 440 | if (sstd_index > NUM_TOTAL_TRANSACTIONS) return TRANSACTION_TYPE_ERROR; |
457 | SSTD_t *trans = &Transaction_table[sstd_index]; | 441 | split_transaction_desc_t *trans = &split_transaction_table[sstd_index]; |
458 | # endif | 442 | |
443 | if (!trans->status) return TRANSACTION_TYPE_ERROR; // not registered | ||
444 | |||
459 | cli(); | 445 | cli(); |
460 | 446 | ||
461 | // signal to the target that we want to start a transaction | 447 | // signal to the target that we want to start a transaction |
@@ -463,27 +449,11 @@ int soft_serial_transaction(int sstd_index) { | |||
463 | serial_low(); | 449 | serial_low(); |
464 | _delay_us(SLAVE_INT_WIDTH_US); | 450 | _delay_us(SLAVE_INT_WIDTH_US); |
465 | 451 | ||
466 | # ifndef SERIAL_USE_MULTI_TRANSACTION | ||
467 | // wait for the target response | ||
468 | serial_input_with_pullup(); | ||
469 | _delay_us(SLAVE_INT_RESPONSE_TIME); | ||
470 | |||
471 | // check if the target is present | ||
472 | if (serial_read_pin()) { | ||
473 | // target failed to pull the line low, assume not present | ||
474 | serial_output(); | ||
475 | serial_high(); | ||
476 | *trans->status = TRANSACTION_NO_RESPONSE; | ||
477 | sei(); | ||
478 | return TRANSACTION_NO_RESPONSE; | ||
479 | } | ||
480 | |||
481 | # else | ||
482 | // send transaction table index | 452 | // send transaction table index |
483 | int tid = (sstd_index << 3) | (7 & nibble_bits_count(sstd_index)); | 453 | int tid = (sstd_index << 3) | (7 & nibble_bits_count(sstd_index)); |
484 | sync_send(); | 454 | sync_send(); |
485 | _delay_sub_us(TID_SEND_ADJUST); | 455 | _delay_sub_us(TID_SEND_ADJUST); |
486 | serial_write_chunk(tid, 7); | 456 | serial_write_chunk(tid, 8); |
487 | serial_delay_half1(); | 457 | serial_delay_half1(); |
488 | 458 | ||
489 | // wait for the target response (step1 low->high) | 459 | // wait for the target response (step1 low->high) |
@@ -504,12 +474,11 @@ int soft_serial_transaction(int sstd_index) { | |||
504 | } | 474 | } |
505 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT); | 475 | _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT); |
506 | } | 476 | } |
507 | # endif | ||
508 | 477 | ||
509 | // initiator recive phase | 478 | // initiator recive phase |
510 | // if the target is present syncronize with it | 479 | // if the target is present syncronize with it |
511 | if (trans->target2initiator_buffer_size > 0) { | 480 | if (trans->target2initiator_buffer_size > 0) { |
512 | if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer, trans->target2initiator_buffer_size)) { | 481 | if (!serial_recive_packet((uint8_t *)split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size)) { |
513 | serial_output(); | 482 | serial_output(); |
514 | serial_high(); | 483 | serial_high(); |
515 | *trans->status = TRANSACTION_DATA_ERROR; | 484 | *trans->status = TRANSACTION_DATA_ERROR; |
@@ -523,7 +492,7 @@ int soft_serial_transaction(int sstd_index) { | |||
523 | 492 | ||
524 | // initiator send phase | 493 | // initiator send phase |
525 | if (trans->initiator2target_buffer_size > 0) { | 494 | if (trans->initiator2target_buffer_size > 0) { |
526 | serial_send_packet((uint8_t *)trans->initiator2target_buffer, trans->initiator2target_buffer_size); | 495 | serial_send_packet((uint8_t *)split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size); |
527 | } | 496 | } |
528 | 497 | ||
529 | // always, release the line when not in use | 498 | // always, release the line when not in use |
@@ -534,9 +503,8 @@ int soft_serial_transaction(int sstd_index) { | |||
534 | return TRANSACTION_END; | 503 | return TRANSACTION_END; |
535 | } | 504 | } |
536 | 505 | ||
537 | # ifdef SERIAL_USE_MULTI_TRANSACTION | ||
538 | int soft_serial_get_and_clean_status(int sstd_index) { | 506 | int soft_serial_get_and_clean_status(int sstd_index) { |
539 | SSTD_t *trans = &Transaction_table[sstd_index]; | 507 | split_transaction_desc_t *trans = &split_transaction_table[sstd_index]; |
540 | cli(); | 508 | cli(); |
541 | int retval = *trans->status; | 509 | int retval = *trans->status; |
542 | *trans->status = 0; | 510 | *trans->status = 0; |
@@ -544,8 +512,6 @@ int soft_serial_get_and_clean_status(int sstd_index) { | |||
544 | sei(); | 512 | sei(); |
545 | return retval; | 513 | return retval; |
546 | } | 514 | } |
547 | # endif | ||
548 | |||
549 | #endif | 515 | #endif |
550 | 516 | ||
551 | // Helix serial.c history | 517 | // Helix serial.c history |
diff --git a/drivers/avr/serial.h b/drivers/avr/serial.h deleted file mode 100644 index 53e66cf90..000000000 --- a/drivers/avr/serial.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <stdbool.h> | ||
4 | |||
5 | // ///////////////////////////////////////////////////////////////// | ||
6 | // Need Soft Serial defines in config.h | ||
7 | // ///////////////////////////////////////////////////////////////// | ||
8 | // ex. | ||
9 | // #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 | ||
10 | // OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 | ||
11 | // // 1: about 137kbps (default) | ||
12 | // // 2: about 75kbps | ||
13 | // // 3: about 39kbps | ||
14 | // // 4: about 26kbps | ||
15 | // // 5: about 20kbps | ||
16 | // | ||
17 | // //// USE simple API (using signle-type transaction function) | ||
18 | // /* nothing */ | ||
19 | // //// USE flexible API (using multi-type transaction function) | ||
20 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
21 | // | ||
22 | // ///////////////////////////////////////////////////////////////// | ||
23 | |||
24 | // Soft Serial Transaction Descriptor | ||
25 | typedef struct _SSTD_t { | ||
26 | uint8_t *status; | ||
27 | uint8_t initiator2target_buffer_size; | ||
28 | uint8_t *initiator2target_buffer; | ||
29 | uint8_t target2initiator_buffer_size; | ||
30 | uint8_t *target2initiator_buffer; | ||
31 | } SSTD_t; | ||
32 | #define TID_LIMIT(table) (sizeof(table) / sizeof(SSTD_t)) | ||
33 | |||
34 | // initiator is transaction start side | ||
35 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); | ||
36 | // target is interrupt accept side | ||
37 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); | ||
38 | |||
39 | // initiator resullt | ||
40 | #define TRANSACTION_END 0 | ||
41 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
42 | #define TRANSACTION_DATA_ERROR 0x2 | ||
43 | #define TRANSACTION_TYPE_ERROR 0x4 | ||
44 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
45 | int soft_serial_transaction(void); | ||
46 | #else | ||
47 | int soft_serial_transaction(int sstd_index); | ||
48 | #endif | ||
49 | |||
50 | // target status | ||
51 | // *SSTD_t.status has | ||
52 | // initiator: | ||
53 | // TRANSACTION_END | ||
54 | // or TRANSACTION_NO_RESPONSE | ||
55 | // or TRANSACTION_DATA_ERROR | ||
56 | // target: | ||
57 | // TRANSACTION_DATA_ERROR | ||
58 | // or TRANSACTION_ACCEPTED | ||
59 | #define TRANSACTION_ACCEPTED 0x8 | ||
60 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
61 | int soft_serial_get_and_clean_status(int sstd_index); | ||
62 | #endif | ||
diff --git a/drivers/awinic/aw20216.c b/drivers/awinic/aw20216.c new file mode 100644 index 000000000..236c42a3c --- /dev/null +++ b/drivers/awinic/aw20216.c | |||
@@ -0,0 +1,166 @@ | |||
1 | /* Copyright 2021 Jasper Chan | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include "aw20216.h" | ||
18 | #include "spi_master.h" | ||
19 | |||
20 | /* The AW20216 appears to be somewhat similar to the IS31FL743, although quite | ||
21 | * a few things are different, such as the command byte format and page ordering. | ||
22 | * The LED addresses start from 0x00 instead of 0x01. | ||
23 | */ | ||
24 | #define AWINIC_ID 0b1010 << 4 | ||
25 | |||
26 | #define AW_PAGE_FUNCTION 0x00 << 1 // PG0, Function registers | ||
27 | #define AW_PAGE_PWM 0x01 << 1 // PG1, LED PWM control | ||
28 | #define AW_PAGE_SCALING 0x02 << 1 // PG2, LED current scaling control | ||
29 | #define AW_PAGE_PATCHOICE 0x03 << 1 // PG3, Pattern choice? | ||
30 | #define AW_PAGE_PWMSCALING 0x04 << 1 // PG4, LED PWM + Scaling control? | ||
31 | |||
32 | #define AW_WRITE 0 | ||
33 | #define AW_READ 1 | ||
34 | |||
35 | #define AW_REG_CONFIGURATION 0x00 // PG0 | ||
36 | #define AW_REG_GLOBALCURRENT 0x01 // PG0 | ||
37 | |||
38 | // Default value of AW_REG_CONFIGURATION | ||
39 | // D7:D4 = 1011, SWSEL (SW1~SW12 active) | ||
40 | // D3 = 0?, reserved (apparently this should be 1 but it doesn't seem to matter) | ||
41 | // D2:D1 = 00, OSDE (open/short detection enable) | ||
42 | // D0 = 0, CHIPEN (write 1 to enable LEDs when hardware enable pulled high) | ||
43 | #define AW_CONFIG_DEFAULT 0b10110000 | ||
44 | #define AW_CHIPEN 1 | ||
45 | |||
46 | #ifndef AW_SCALING_MAX | ||
47 | # define AW_SCALING_MAX 150 | ||
48 | #endif | ||
49 | |||
50 | #ifndef AW_GLOBAL_CURRENT_MAX | ||
51 | # define AW_GLOBAL_CURRENT_MAX 150 | ||
52 | #endif | ||
53 | |||
54 | #ifndef DRIVER_1_CS | ||
55 | # define DRIVER_1_CS B13 | ||
56 | #endif | ||
57 | |||
58 | #ifndef DRIVER_1_EN | ||
59 | # define DRIVER_1_EN C13 | ||
60 | #endif | ||
61 | |||
62 | uint8_t g_spi_transfer_buffer[20] = {0}; | ||
63 | aw_led g_pwm_buffer[DRIVER_LED_TOTAL]; | ||
64 | bool g_pwm_buffer_update_required[DRIVER_LED_TOTAL]; | ||
65 | |||
66 | bool AW20216_write_register(pin_t slave_pin, uint8_t page, uint8_t reg, uint8_t data) { | ||
67 | // Do we need to call spi_stop() if this fails? | ||
68 | if (!spi_start(slave_pin, false, 0, 16)) { | ||
69 | return false; | ||
70 | } | ||
71 | |||
72 | g_spi_transfer_buffer[0] = (AWINIC_ID | page | AW_WRITE); | ||
73 | g_spi_transfer_buffer[1] = reg; | ||
74 | g_spi_transfer_buffer[2] = data; | ||
75 | |||
76 | if (spi_transmit(g_spi_transfer_buffer, 3) != SPI_STATUS_SUCCESS) { | ||
77 | spi_stop(); | ||
78 | return false; | ||
79 | } | ||
80 | spi_stop(); | ||
81 | return true; | ||
82 | } | ||
83 | |||
84 | bool AW20216_init_scaling(void) { | ||
85 | // Set constant current to the max, control brightness with PWM | ||
86 | aw_led led; | ||
87 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | ||
88 | led = g_aw_leds[i]; | ||
89 | if (led.driver == 0) { | ||
90 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX); | ||
91 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX); | ||
92 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX); | ||
93 | } | ||
94 | #ifdef DRIVER_2_CS | ||
95 | else if (led.driver == 1) { | ||
96 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.r, AW_SCALING_MAX); | ||
97 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.g, AW_SCALING_MAX); | ||
98 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_SCALING, led.b, AW_SCALING_MAX); | ||
99 | } | ||
100 | #endif | ||
101 | } | ||
102 | return true; | ||
103 | } | ||
104 | |||
105 | bool AW20216_soft_enable(void) { | ||
106 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN); | ||
107 | #ifdef DRIVER_2_CS | ||
108 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_CONFIGURATION, AW_CONFIG_DEFAULT | AW_CHIPEN); | ||
109 | #endif | ||
110 | return true; | ||
111 | } | ||
112 | |||
113 | void AW20216_update_pwm(int index, uint8_t red, uint8_t green, uint8_t blue) { | ||
114 | aw_led led = g_aw_leds[index]; | ||
115 | if (led.driver == 0) { | ||
116 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.r, red); | ||
117 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.g, green); | ||
118 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_PWM, led.b, blue); | ||
119 | } | ||
120 | #ifdef DRIVER_2_CS | ||
121 | else if (led.driver == 1) { | ||
122 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.r, red); | ||
123 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.g, green); | ||
124 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_PWM, led.b, blue); | ||
125 | } | ||
126 | #endif | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | void AW20216_init(void) { | ||
131 | // All LEDs should start with all scaling and PWM registers as off | ||
132 | setPinOutput(DRIVER_1_EN); | ||
133 | writePinHigh(DRIVER_1_EN); | ||
134 | AW20216_write_register(DRIVER_1_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX); | ||
135 | #ifdef DRIVER_2_EN | ||
136 | setPinOutput(DRIVER_2_EN); | ||
137 | writePinHigh(DRIVER_2_EN); | ||
138 | AW20216_write_register(DRIVER_2_CS, AW_PAGE_FUNCTION, AW_REG_GLOBALCURRENT, AW_GLOBAL_CURRENT_MAX); | ||
139 | #endif | ||
140 | AW20216_init_scaling(); | ||
141 | AW20216_soft_enable(); | ||
142 | return; | ||
143 | } | ||
144 | |||
145 | void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { | ||
146 | g_pwm_buffer[index].r = red; | ||
147 | g_pwm_buffer[index].g = green; | ||
148 | g_pwm_buffer[index].b = blue; | ||
149 | g_pwm_buffer_update_required[index] = true; | ||
150 | return; | ||
151 | } | ||
152 | void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { | ||
153 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | ||
154 | AW20216_set_color(i, red, green, blue); | ||
155 | } | ||
156 | return; | ||
157 | } | ||
158 | void AW20216_update_pwm_buffers(void) { | ||
159 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | ||
160 | if (g_pwm_buffer_update_required[i]) { | ||
161 | AW20216_update_pwm(i, g_pwm_buffer[i].r, g_pwm_buffer[i].g, g_pwm_buffer[i].b); | ||
162 | g_pwm_buffer_update_required[i] = false; | ||
163 | } | ||
164 | } | ||
165 | return; | ||
166 | } | ||
diff --git a/drivers/awinic/aw20216.h b/drivers/awinic/aw20216.h new file mode 100644 index 000000000..9c6865cc8 --- /dev/null +++ b/drivers/awinic/aw20216.h | |||
@@ -0,0 +1,251 @@ | |||
1 | /* Copyright 2021 Jasper Chan (Gigahawk) | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include <stdint.h> | ||
20 | #include <stdbool.h> | ||
21 | |||
22 | typedef struct aw_led { | ||
23 | uint8_t driver : 2; | ||
24 | uint8_t r; | ||
25 | uint8_t g; | ||
26 | uint8_t b; | ||
27 | } aw_led; | ||
28 | |||
29 | extern const aw_led g_aw_leds[DRIVER_LED_TOTAL]; | ||
30 | |||
31 | void AW20216_init(void); | ||
32 | void AW20216_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); | ||
33 | void AW20216_set_color_all(uint8_t red, uint8_t green, uint8_t blue); | ||
34 | void AW20216_update_pwm_buffers(void); | ||
35 | |||
36 | #define CS1_SW1 0x00 | ||
37 | #define CS2_SW1 0x01 | ||
38 | #define CS3_SW1 0x02 | ||
39 | #define CS4_SW1 0x03 | ||
40 | #define CS5_SW1 0x04 | ||
41 | #define CS6_SW1 0x05 | ||
42 | #define CS7_SW1 0x06 | ||
43 | #define CS8_SW1 0x07 | ||
44 | #define CS9_SW1 0x08 | ||
45 | #define CS10_SW1 0x09 | ||
46 | #define CS11_SW1 0x0A | ||
47 | #define CS12_SW1 0x0B | ||
48 | #define CS13_SW1 0x0C | ||
49 | #define CS14_SW1 0x0D | ||
50 | #define CS15_SW1 0x0E | ||
51 | #define CS16_SW1 0x0F | ||
52 | #define CS17_SW1 0x10 | ||
53 | #define CS18_SW1 0x11 | ||
54 | #define CS1_SW2 0x12 | ||
55 | #define CS2_SW2 0x13 | ||
56 | #define CS3_SW2 0x14 | ||
57 | #define CS4_SW2 0x15 | ||
58 | #define CS5_SW2 0x16 | ||
59 | #define CS6_SW2 0x17 | ||
60 | #define CS7_SW2 0x18 | ||
61 | #define CS8_SW2 0x19 | ||
62 | #define CS9_SW2 0x1A | ||
63 | #define CS10_SW2 0x1B | ||
64 | #define CS11_SW2 0x1C | ||
65 | #define CS12_SW2 0x1D | ||
66 | #define CS13_SW2 0x1E | ||
67 | #define CS14_SW2 0x1F | ||
68 | #define CS15_SW2 0x20 | ||
69 | #define CS16_SW2 0x21 | ||
70 | #define CS17_SW2 0x22 | ||
71 | #define CS18_SW2 0x23 | ||
72 | #define CS1_SW3 0x24 | ||
73 | #define CS2_SW3 0x25 | ||
74 | #define CS3_SW3 0x26 | ||
75 | #define CS4_SW3 0x27 | ||
76 | #define CS5_SW3 0x28 | ||
77 | #define CS6_SW3 0x29 | ||
78 | #define CS7_SW3 0x2A | ||
79 | #define CS8_SW3 0x2B | ||
80 | #define CS9_SW3 0x2C | ||
81 | #define CS10_SW3 0x2D | ||
82 | #define CS11_SW3 0x2E | ||
83 | #define CS12_SW3 0x2F | ||
84 | #define CS13_SW3 0x30 | ||
85 | #define CS14_SW3 0x31 | ||
86 | #define CS15_SW3 0x32 | ||
87 | #define CS16_SW3 0x33 | ||
88 | #define CS17_SW3 0x34 | ||
89 | #define CS18_SW3 0x35 | ||
90 | #define CS1_SW4 0x36 | ||
91 | #define CS2_SW4 0x37 | ||
92 | #define CS3_SW4 0x38 | ||
93 | #define CS4_SW4 0x39 | ||
94 | #define CS5_SW4 0x3A | ||
95 | #define CS6_SW4 0x3B | ||
96 | #define CS7_SW4 0x3C | ||
97 | #define CS8_SW4 0x3D | ||
98 | #define CS9_SW4 0x3E | ||
99 | #define CS10_SW4 0x3F | ||
100 | #define CS11_SW4 0x40 | ||
101 | #define CS12_SW4 0x41 | ||
102 | #define CS13_SW4 0x42 | ||
103 | #define CS14_SW4 0x43 | ||
104 | #define CS15_SW4 0x44 | ||
105 | #define CS16_SW4 0x45 | ||
106 | #define CS17_SW4 0x46 | ||
107 | #define CS18_SW4 0x47 | ||
108 | #define CS1_SW5 0x48 | ||
109 | #define CS2_SW5 0x49 | ||
110 | #define CS3_SW5 0x4A | ||
111 | #define CS4_SW5 0x4B | ||
112 | #define CS5_SW5 0x4C | ||
113 | #define CS6_SW5 0x4D | ||
114 | #define CS7_SW5 0x4E | ||
115 | #define CS8_SW5 0x4F | ||
116 | #define CS9_SW5 0x50 | ||
117 | #define CS10_SW5 0x51 | ||
118 | #define CS11_SW5 0x52 | ||
119 | #define CS12_SW5 0x53 | ||
120 | #define CS13_SW5 0x54 | ||
121 | #define CS14_SW5 0x55 | ||
122 | #define CS15_SW5 0x56 | ||
123 | #define CS16_SW5 0x57 | ||
124 | #define CS17_SW5 0x58 | ||
125 | #define CS18_SW5 0x59 | ||
126 | #define CS1_SW6 0x5A | ||
127 | #define CS2_SW6 0x5B | ||
128 | #define CS3_SW6 0x5C | ||
129 | #define CS4_SW6 0x5D | ||
130 | #define CS5_SW6 0x5E | ||
131 | #define CS6_SW6 0x5F | ||
132 | #define CS7_SW6 0x60 | ||
133 | #define CS8_SW6 0x61 | ||
134 | #define CS9_SW6 0x62 | ||
135 | #define CS10_SW6 0x63 | ||
136 | #define CS11_SW6 0x64 | ||
137 | #define CS12_SW6 0x65 | ||
138 | #define CS13_SW6 0x66 | ||
139 | #define CS14_SW6 0x67 | ||
140 | #define CS15_SW6 0x68 | ||
141 | #define CS16_SW6 0x69 | ||
142 | #define CS17_SW6 0x6A | ||
143 | #define CS18_SW6 0x6B | ||
144 | #define CS1_SW7 0x6C | ||
145 | #define CS2_SW7 0x6D | ||
146 | #define CS3_SW7 0x6E | ||
147 | #define CS4_SW7 0x6F | ||
148 | #define CS5_SW7 0x70 | ||
149 | #define CS6_SW7 0x71 | ||
150 | #define CS7_SW7 0x72 | ||
151 | #define CS8_SW7 0x73 | ||
152 | #define CS9_SW7 0x74 | ||
153 | #define CS10_SW7 0x75 | ||
154 | #define CS11_SW7 0x76 | ||
155 | #define CS12_SW7 0x77 | ||
156 | #define CS13_SW7 0x78 | ||
157 | #define CS14_SW7 0x79 | ||
158 | #define CS15_SW7 0x7A | ||
159 | #define CS16_SW7 0x7B | ||
160 | #define CS17_SW7 0x7C | ||
161 | #define CS18_SW7 0x7D | ||
162 | #define CS1_SW8 0x7E | ||
163 | #define CS2_SW8 0x7F | ||
164 | #define CS3_SW8 0x80 | ||
165 | #define CS4_SW8 0x81 | ||
166 | #define CS5_SW8 0x82 | ||
167 | #define CS6_SW8 0x83 | ||
168 | #define CS7_SW8 0x84 | ||
169 | #define CS8_SW8 0x85 | ||
170 | #define CS9_SW8 0x86 | ||
171 | #define CS10_SW8 0x87 | ||
172 | #define CS11_SW8 0x88 | ||
173 | #define CS12_SW8 0x89 | ||
174 | #define CS13_SW8 0x8A | ||
175 | #define CS14_SW8 0x8B | ||
176 | #define CS15_SW8 0x8C | ||
177 | #define CS16_SW8 0x8D | ||
178 | #define CS17_SW8 0x8E | ||
179 | #define CS18_SW8 0x8F | ||
180 | #define CS1_SW9 0x90 | ||
181 | #define CS2_SW9 0x91 | ||
182 | #define CS3_SW9 0x92 | ||
183 | #define CS4_SW9 0x93 | ||
184 | #define CS5_SW9 0x94 | ||
185 | #define CS6_SW9 0x95 | ||
186 | #define CS7_SW9 0x96 | ||
187 | #define CS8_SW9 0x97 | ||
188 | #define CS9_SW9 0x98 | ||
189 | #define CS10_SW9 0x99 | ||
190 | #define CS11_SW9 0x9A | ||
191 | #define CS12_SW9 0x9B | ||
192 | #define CS13_SW9 0x9C | ||
193 | #define CS14_SW9 0x9D | ||
194 | #define CS15_SW9 0x9E | ||
195 | #define CS16_SW9 0x9F | ||
196 | #define CS17_SW9 0xA0 | ||
197 | #define CS18_SW9 0xA1 | ||
198 | #define CS1_SW10 0xA2 | ||
199 | #define CS2_SW10 0xA3 | ||
200 | #define CS3_SW10 0xA4 | ||
201 | #define CS4_SW10 0xA5 | ||
202 | #define CS5_SW10 0xA6 | ||
203 | #define CS6_SW10 0xA7 | ||
204 | #define CS7_SW10 0xA8 | ||
205 | #define CS8_SW10 0xA9 | ||
206 | #define CS9_SW10 0xAA | ||
207 | #define CS10_SW10 0xAB | ||
208 | #define CS11_SW10 0xAC | ||
209 | #define CS12_SW10 0xAD | ||
210 | #define CS13_SW10 0xAE | ||
211 | #define CS14_SW10 0xAF | ||
212 | #define CS15_SW10 0xB0 | ||
213 | #define CS16_SW10 0xB1 | ||
214 | #define CS17_SW10 0xB2 | ||
215 | #define CS18_SW10 0xB3 | ||
216 | #define CS1_SW11 0xB4 | ||
217 | #define CS2_SW11 0xB5 | ||
218 | #define CS3_SW11 0xB6 | ||
219 | #define CS4_SW11 0xB7 | ||
220 | #define CS5_SW11 0xB8 | ||
221 | #define CS6_SW11 0xB9 | ||
222 | #define CS7_SW11 0xBA | ||
223 | #define CS8_SW11 0xBB | ||
224 | #define CS9_SW11 0xBC | ||
225 | #define CS10_SW11 0xBD | ||
226 | #define CS11_SW11 0xBE | ||
227 | #define CS12_SW11 0xBF | ||
228 | #define CS13_SW11 0xC0 | ||
229 | #define CS14_SW11 0xC1 | ||
230 | #define CS15_SW11 0xC2 | ||
231 | #define CS16_SW11 0xC3 | ||
232 | #define CS17_SW11 0xC4 | ||
233 | #define CS18_SW11 0xC5 | ||
234 | #define CS1_SW12 0xC6 | ||
235 | #define CS2_SW12 0xC7 | ||
236 | #define CS3_SW12 0xC8 | ||
237 | #define CS4_SW12 0xC9 | ||
238 | #define CS5_SW12 0xCA | ||
239 | #define CS6_SW12 0xCB | ||
240 | #define CS7_SW12 0xCC | ||
241 | #define CS8_SW12 0xCD | ||
242 | #define CS9_SW12 0xCE | ||
243 | #define CS10_SW12 0xCF | ||
244 | #define CS11_SW12 0xD0 | ||
245 | #define CS12_SW12 0xD1 | ||
246 | #define CS13_SW12 0xD2 | ||
247 | #define CS14_SW12 0xD3 | ||
248 | #define CS15_SW12 0xD4 | ||
249 | #define CS16_SW12 0xD5 | ||
250 | #define CS17_SW12 0xD6 | ||
251 | #define CS18_SW12 0xD7 | ||
diff --git a/drivers/chibios/serial.c b/drivers/chibios/serial.c index 54f7e1321..f54fbcee4 100644 --- a/drivers/chibios/serial.c +++ b/drivers/chibios/serial.c | |||
@@ -74,21 +74,12 @@ static THD_FUNCTION(Thread1, arg) { | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | static SSTD_t *Transaction_table = NULL; | 77 | void soft_serial_initiator_init(void) { |
78 | static uint8_t Transaction_table_size = 0; | ||
79 | |||
80 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) { | ||
81 | Transaction_table = sstd_table; | ||
82 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
83 | |||
84 | serial_output(); | 78 | serial_output(); |
85 | serial_high(); | 79 | serial_high(); |
86 | } | 80 | } |
87 | 81 | ||
88 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) { | 82 | void soft_serial_target_init(void) { |
89 | Transaction_table = sstd_table; | ||
90 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
91 | |||
92 | serial_input(); | 83 | serial_input(); |
93 | 84 | ||
94 | palEnablePadEvent(PAL_PORT(SOFT_SERIAL_PIN), PAL_PAD(SOFT_SERIAL_PIN), PAL_EVENT_MODE_FALLING_EDGE); | 85 | palEnablePadEvent(PAL_PORT(SOFT_SERIAL_PIN), PAL_PAD(SOFT_SERIAL_PIN), PAL_EVENT_MODE_FALLING_EDGE); |
@@ -154,16 +145,14 @@ void interrupt_handler(void *arg) { | |||
154 | uint8_t checksum_computed = 0; | 145 | uint8_t checksum_computed = 0; |
155 | int sstd_index = 0; | 146 | int sstd_index = 0; |
156 | 147 | ||
157 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
158 | sstd_index = serial_read_byte(); | 148 | sstd_index = serial_read_byte(); |
159 | sync_send(); | 149 | sync_send(); |
160 | #endif | ||
161 | 150 | ||
162 | SSTD_t *trans = &Transaction_table[sstd_index]; | 151 | split_transaction_desc_t *trans = &split_transaction_table[sstd_index]; |
163 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { | 152 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { |
164 | trans->initiator2target_buffer[i] = serial_read_byte(); | 153 | split_trans_initiator2target_buffer(trans)[i] = serial_read_byte(); |
165 | sync_send(); | 154 | sync_send(); |
166 | checksum_computed += trans->initiator2target_buffer[i]; | 155 | checksum_computed += split_trans_initiator2target_buffer(trans)[i]; |
167 | } | 156 | } |
168 | checksum_computed ^= 7; | 157 | checksum_computed ^= 7; |
169 | uint8_t checksum_received = serial_read_byte(); | 158 | uint8_t checksum_received = serial_read_byte(); |
@@ -172,12 +161,17 @@ void interrupt_handler(void *arg) { | |||
172 | // wait for the sync to finish sending | 161 | // wait for the sync to finish sending |
173 | serial_delay(); | 162 | serial_delay(); |
174 | 163 | ||
164 | // Allow any slave processing to occur | ||
165 | if (trans->slave_callback) { | ||
166 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); | ||
167 | } | ||
168 | |||
175 | uint8_t checksum = 0; | 169 | uint8_t checksum = 0; |
176 | for (int i = 0; i < trans->target2initiator_buffer_size; ++i) { | 170 | for (int i = 0; i < trans->target2initiator_buffer_size; ++i) { |
177 | serial_write_byte(trans->target2initiator_buffer[i]); | 171 | serial_write_byte(split_trans_target2initiator_buffer(trans)[i]); |
178 | sync_send(); | 172 | sync_send(); |
179 | serial_delay_half(); | 173 | serial_delay_half(); |
180 | checksum += trans->target2initiator_buffer[i]; | 174 | checksum += split_trans_target2initiator_buffer(trans)[i]; |
181 | } | 175 | } |
182 | serial_write_byte(checksum ^ 7); | 176 | serial_write_byte(checksum ^ 7); |
183 | sync_send(); | 177 | sync_send(); |
@@ -206,15 +200,10 @@ void interrupt_handler(void *arg) { | |||
206 | // TRANSACTION_NO_RESPONSE | 200 | // TRANSACTION_NO_RESPONSE |
207 | // TRANSACTION_DATA_ERROR | 201 | // TRANSACTION_DATA_ERROR |
208 | // this code is very time dependent, so we need to disable interrupts | 202 | // this code is very time dependent, so we need to disable interrupts |
209 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
210 | int soft_serial_transaction(void) { | ||
211 | int sstd_index = 0; | ||
212 | #else | ||
213 | int soft_serial_transaction(int sstd_index) { | 203 | int soft_serial_transaction(int sstd_index) { |
214 | #endif | 204 | if (sstd_index > NUM_TOTAL_TRANSACTIONS) return TRANSACTION_TYPE_ERROR; |
215 | 205 | split_transaction_desc_t *trans = &split_transaction_table[sstd_index]; | |
216 | if (sstd_index > Transaction_table_size) return TRANSACTION_TYPE_ERROR; | 206 | if (!trans->status) return TRANSACTION_TYPE_ERROR; // not registered |
217 | SSTD_t *trans = &Transaction_table[sstd_index]; | ||
218 | 207 | ||
219 | // TODO: remove extra delay between transactions | 208 | // TODO: remove extra delay between transactions |
220 | serial_delay(); | 209 | serial_delay(); |
@@ -244,14 +233,13 @@ int soft_serial_transaction(int sstd_index) { | |||
244 | 233 | ||
245 | uint8_t checksum = 0; | 234 | uint8_t checksum = 0; |
246 | // send data to the slave | 235 | // send data to the slave |
247 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
248 | serial_write_byte(sstd_index); // first chunk is transaction id | 236 | serial_write_byte(sstd_index); // first chunk is transaction id |
249 | sync_recv(); | 237 | sync_recv(); |
250 | #endif | 238 | |
251 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { | 239 | for (int i = 0; i < trans->initiator2target_buffer_size; ++i) { |
252 | serial_write_byte(trans->initiator2target_buffer[i]); | 240 | serial_write_byte(split_trans_initiator2target_buffer(trans)[i]); |
253 | sync_recv(); | 241 | sync_recv(); |
254 | checksum += trans->initiator2target_buffer[i]; | 242 | checksum += split_trans_initiator2target_buffer(trans)[i]; |
255 | } | 243 | } |
256 | serial_write_byte(checksum ^ 7); | 244 | serial_write_byte(checksum ^ 7); |
257 | sync_recv(); | 245 | sync_recv(); |
@@ -262,9 +250,9 @@ int soft_serial_transaction(int sstd_index) { | |||
262 | // receive data from the slave | 250 | // receive data from the slave |
263 | uint8_t checksum_computed = 0; | 251 | uint8_t checksum_computed = 0; |
264 | for (int i = 0; i < trans->target2initiator_buffer_size; ++i) { | 252 | for (int i = 0; i < trans->target2initiator_buffer_size; ++i) { |
265 | trans->target2initiator_buffer[i] = serial_read_byte(); | 253 | split_trans_target2initiator_buffer(trans)[i] = serial_read_byte(); |
266 | sync_recv(); | 254 | sync_recv(); |
267 | checksum_computed += trans->target2initiator_buffer[i]; | 255 | checksum_computed += split_trans_target2initiator_buffer(trans)[i]; |
268 | } | 256 | } |
269 | checksum_computed ^= 7; | 257 | checksum_computed ^= 7; |
270 | uint8_t checksum_received = serial_read_byte(); | 258 | uint8_t checksum_received = serial_read_byte(); |
diff --git a/drivers/chibios/serial.h b/drivers/chibios/serial.h deleted file mode 100644 index 0c1857d52..000000000 --- a/drivers/chibios/serial.h +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <stdbool.h> | ||
4 | |||
5 | // ///////////////////////////////////////////////////////////////// | ||
6 | // Need Soft Serial defines in config.h | ||
7 | // ///////////////////////////////////////////////////////////////// | ||
8 | // ex. | ||
9 | // #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 | ||
10 | // OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 | ||
11 | // // 1: about 137kbps (default) | ||
12 | // // 2: about 75kbps | ||
13 | // // 3: about 39kbps | ||
14 | // // 4: about 26kbps | ||
15 | // // 5: about 20kbps | ||
16 | // | ||
17 | // //// USE simple API (using signle-type transaction function) | ||
18 | // /* nothing */ | ||
19 | // //// USE flexible API (using multi-type transaction function) | ||
20 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
21 | // | ||
22 | // ///////////////////////////////////////////////////////////////// | ||
23 | |||
24 | // Soft Serial Transaction Descriptor | ||
25 | typedef struct _SSTD_t { | ||
26 | uint8_t *status; | ||
27 | uint8_t initiator2target_buffer_size; | ||
28 | uint8_t *initiator2target_buffer; | ||
29 | uint8_t target2initiator_buffer_size; | ||
30 | uint8_t *target2initiator_buffer; | ||
31 | } SSTD_t; | ||
32 | #define TID_LIMIT(table) (sizeof(table) / sizeof(SSTD_t)) | ||
33 | |||
34 | // initiator is transaction start side | ||
35 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); | ||
36 | // target is interrupt accept side | ||
37 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); | ||
38 | |||
39 | // initiator result | ||
40 | #define TRANSACTION_END 0 | ||
41 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
42 | #define TRANSACTION_DATA_ERROR 0x2 | ||
43 | #define TRANSACTION_TYPE_ERROR 0x4 | ||
44 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
45 | int soft_serial_transaction(void); | ||
46 | #else | ||
47 | int soft_serial_transaction(int sstd_index); | ||
48 | #endif | ||
49 | |||
50 | // target status | ||
51 | // *SSTD_t.status has | ||
52 | // initiator: | ||
53 | // TRANSACTION_END | ||
54 | // or TRANSACTION_NO_RESPONSE | ||
55 | // or TRANSACTION_DATA_ERROR | ||
56 | // target: | ||
57 | // TRANSACTION_DATA_ERROR | ||
58 | // or TRANSACTION_ACCEPTED | ||
59 | #define TRANSACTION_ACCEPTED 0x8 | ||
60 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
61 | int soft_serial_get_and_clean_status(int sstd_index); | ||
62 | #endif | ||
diff --git a/drivers/chibios/serial_usart.c b/drivers/chibios/serial_usart.c index cae29388c..9f180d2d7 100644 --- a/drivers/chibios/serial_usart.c +++ b/drivers/chibios/serial_usart.c | |||
@@ -113,37 +113,29 @@ void usart_slave_init(void) { | |||
113 | chThdCreateStatic(waSlaveThread, sizeof(waSlaveThread), HIGHPRIO, SlaveThread, NULL); | 113 | chThdCreateStatic(waSlaveThread, sizeof(waSlaveThread), HIGHPRIO, SlaveThread, NULL); |
114 | } | 114 | } |
115 | 115 | ||
116 | static SSTD_t* Transaction_table = NULL; | 116 | void soft_serial_initiator_init(void) { usart_master_init(); } |
117 | static uint8_t Transaction_table_size = 0; | ||
118 | 117 | ||
119 | void soft_serial_initiator_init(SSTD_t* sstd_table, int sstd_table_size) { | 118 | void soft_serial_target_init(void) { usart_slave_init(); } |
120 | Transaction_table = sstd_table; | ||
121 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
122 | |||
123 | usart_master_init(); | ||
124 | } | ||
125 | |||
126 | void soft_serial_target_init(SSTD_t* sstd_table, int sstd_table_size) { | ||
127 | Transaction_table = sstd_table; | ||
128 | Transaction_table_size = (uint8_t)sstd_table_size; | ||
129 | |||
130 | usart_slave_init(); | ||
131 | } | ||
132 | 119 | ||
133 | void handle_soft_serial_slave(void) { | 120 | void handle_soft_serial_slave(void) { |
134 | uint8_t sstd_index = sdGet(&SERIAL_USART_DRIVER); // first chunk is always transaction id | 121 | uint8_t sstd_index = sdGet(&SERIAL_USART_DRIVER); // first chunk is always transaction id |
135 | SSTD_t* trans = &Transaction_table[sstd_index]; | 122 | split_transaction_desc_t* trans = &split_transaction_table[sstd_index]; |
136 | 123 | ||
137 | // Always write back the sstd_index as part of a basic handshake | 124 | // Always write back the sstd_index as part of a basic handshake |
138 | sstd_index ^= HANDSHAKE_MAGIC; | 125 | sstd_index ^= HANDSHAKE_MAGIC; |
139 | sdWrite(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index)); | 126 | sdWrite(&SERIAL_USART_DRIVER, &sstd_index, sizeof(sstd_index)); |
140 | 127 | ||
141 | if (trans->initiator2target_buffer_size) { | 128 | if (trans->initiator2target_buffer_size) { |
142 | sdRead(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size); | 129 | sdRead(&SERIAL_USART_DRIVER, split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size); |
130 | } | ||
131 | |||
132 | // Allow any slave processing to occur | ||
133 | if (trans->slave_callback) { | ||
134 | trans->slave_callback(trans->initiator2target_buffer_size, split_trans_initiator2target_buffer(trans), trans->target2initiator_buffer_size, split_trans_target2initiator_buffer(trans)); | ||
143 | } | 135 | } |
144 | 136 | ||
145 | if (trans->target2initiator_buffer_size) { | 137 | if (trans->target2initiator_buffer_size) { |
146 | sdWrite(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size); | 138 | sdWrite(&SERIAL_USART_DRIVER, split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size); |
147 | } | 139 | } |
148 | 140 | ||
149 | if (trans->status) { | 141 | if (trans->status) { |
@@ -160,17 +152,14 @@ void handle_soft_serial_slave(void) { | |||
160 | // TRANSACTION_END | 152 | // TRANSACTION_END |
161 | // TRANSACTION_NO_RESPONSE | 153 | // TRANSACTION_NO_RESPONSE |
162 | // TRANSACTION_DATA_ERROR | 154 | // TRANSACTION_DATA_ERROR |
163 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
164 | int soft_serial_transaction(void) { | ||
165 | uint8_t sstd_index = 0; | ||
166 | #else | ||
167 | int soft_serial_transaction(int index) { | 155 | int soft_serial_transaction(int index) { |
168 | uint8_t sstd_index = index; | 156 | uint8_t sstd_index = index; |
169 | #endif | ||
170 | 157 | ||
171 | if (sstd_index > Transaction_table_size) return TRANSACTION_TYPE_ERROR; | 158 | if (sstd_index > NUM_TOTAL_TRANSACTIONS) return TRANSACTION_TYPE_ERROR; |
172 | SSTD_t* trans = &Transaction_table[sstd_index]; | 159 | split_transaction_desc_t* trans = &split_transaction_table[sstd_index]; |
173 | msg_t res = 0; | 160 | msg_t res = 0; |
161 | |||
162 | if (!trans->status) return TRANSACTION_TYPE_ERROR; // not registered | ||
174 | 163 | ||
175 | sdClear(&SERIAL_USART_DRIVER); | 164 | sdClear(&SERIAL_USART_DRIVER); |
176 | 165 | ||
@@ -189,7 +178,7 @@ int soft_serial_transaction(int index) { | |||
189 | } | 178 | } |
190 | 179 | ||
191 | if (trans->initiator2target_buffer_size) { | 180 | if (trans->initiator2target_buffer_size) { |
192 | res = sdWriteTimeout(&SERIAL_USART_DRIVER, trans->initiator2target_buffer, trans->initiator2target_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT)); | 181 | res = sdWriteTimeout(&SERIAL_USART_DRIVER, split_trans_initiator2target_buffer(trans), trans->initiator2target_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT)); |
193 | if (res < 0) { | 182 | if (res < 0) { |
194 | dprintf("serial::usart_transmit NO_RESPONSE\n"); | 183 | dprintf("serial::usart_transmit NO_RESPONSE\n"); |
195 | return TRANSACTION_NO_RESPONSE; | 184 | return TRANSACTION_NO_RESPONSE; |
@@ -197,7 +186,7 @@ int soft_serial_transaction(int index) { | |||
197 | } | 186 | } |
198 | 187 | ||
199 | if (trans->target2initiator_buffer_size) { | 188 | if (trans->target2initiator_buffer_size) { |
200 | res = sdReadTimeout(&SERIAL_USART_DRIVER, trans->target2initiator_buffer, trans->target2initiator_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT)); | 189 | res = sdReadTimeout(&SERIAL_USART_DRIVER, split_trans_target2initiator_buffer(trans), trans->target2initiator_buffer_size, TIME_MS2I(SERIAL_USART_TIMEOUT)); |
201 | if (res < 0) { | 190 | if (res < 0) { |
202 | dprintf("serial::usart_receive NO_RESPONSE\n"); | 191 | dprintf("serial::usart_receive NO_RESPONSE\n"); |
203 | return TRANSACTION_NO_RESPONSE; | 192 | return TRANSACTION_NO_RESPONSE; |
diff --git a/drivers/chibios/spi_master.c b/drivers/chibios/spi_master.c index 4852a6eba..28ddcbb2b 100644 --- a/drivers/chibios/spi_master.c +++ b/drivers/chibios/spi_master.c | |||
@@ -18,8 +18,13 @@ | |||
18 | 18 | ||
19 | #include "timer.h" | 19 | #include "timer.h" |
20 | 20 | ||
21 | static pin_t currentSlavePin = NO_PIN; | 21 | static pin_t currentSlavePin = NO_PIN; |
22 | static SPIConfig spiConfig = {false, NULL, 0, 0, 0, 0}; | 22 | |
23 | #if defined(K20x) || defined(KL2x) | ||
24 | static SPIConfig spiConfig = {NULL, 0, 0, 0}; | ||
25 | #else | ||
26 | static SPIConfig spiConfig = {false, NULL, 0, 0, 0, 0}; | ||
27 | #endif | ||
23 | 28 | ||
24 | __attribute__((weak)) void spi_init(void) { | 29 | __attribute__((weak)) void spi_init(void) { |
25 | static bool is_initialised = false; | 30 | static bool is_initialised = false; |
@@ -27,15 +32,15 @@ __attribute__((weak)) void spi_init(void) { | |||
27 | is_initialised = true; | 32 | is_initialised = true; |
28 | 33 | ||
29 | // Try releasing special pins for a short time | 34 | // Try releasing special pins for a short time |
30 | palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_INPUT); | 35 | setPinInput(SPI_SCK_PIN); |
31 | palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_INPUT); | 36 | setPinInput(SPI_MOSI_PIN); |
32 | palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_INPUT); | 37 | setPinInput(SPI_MISO_PIN); |
33 | 38 | ||
34 | chThdSleepMilliseconds(10); | 39 | chThdSleepMilliseconds(10); |
35 | #if defined(USE_GPIOV1) | 40 | #if defined(USE_GPIOV1) |
36 | palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); | 41 | palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_PAL_MODE); |
37 | palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); | 42 | palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE); |
38 | palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); | 43 | palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE); |
39 | #else | 44 | #else |
40 | palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); | 45 | palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); |
41 | palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); | 46 | palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); |
@@ -58,6 +63,54 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { | |||
58 | return false; | 63 | return false; |
59 | } | 64 | } |
60 | 65 | ||
66 | #if defined(K20x) || defined(KL2x) | ||
67 | spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1); | ||
68 | |||
69 | if (lsbFirst) { | ||
70 | spiConfig.tar0 |= SPIx_CTARn_LSBFE; | ||
71 | } | ||
72 | |||
73 | switch (mode) { | ||
74 | case 0: | ||
75 | break; | ||
76 | case 1: | ||
77 | spiConfig.tar0 |= SPIx_CTARn_CPHA; | ||
78 | break; | ||
79 | case 2: | ||
80 | spiConfig.tar0 |= SPIx_CTARn_CPOL; | ||
81 | break; | ||
82 | case 3: | ||
83 | spiConfig.tar0 |= SPIx_CTARn_CPHA | SPIx_CTARn_CPOL; | ||
84 | break; | ||
85 | } | ||
86 | |||
87 | switch (roundedDivisor) { | ||
88 | case 2: | ||
89 | spiConfig.tar0 |= SPIx_CTARn_BR(0); | ||
90 | break; | ||
91 | case 4: | ||
92 | spiConfig.tar0 |= SPIx_CTARn_BR(1); | ||
93 | break; | ||
94 | case 8: | ||
95 | spiConfig.tar0 |= SPIx_CTARn_BR(3); | ||
96 | break; | ||
97 | case 16: | ||
98 | spiConfig.tar0 |= SPIx_CTARn_BR(4); | ||
99 | break; | ||
100 | case 32: | ||
101 | spiConfig.tar0 |= SPIx_CTARn_BR(5); | ||
102 | break; | ||
103 | case 64: | ||
104 | spiConfig.tar0 |= SPIx_CTARn_BR(6); | ||
105 | break; | ||
106 | case 128: | ||
107 | spiConfig.tar0 |= SPIx_CTARn_BR(7); | ||
108 | break; | ||
109 | case 256: | ||
110 | spiConfig.tar0 |= SPIx_CTARn_BR(8); | ||
111 | break; | ||
112 | } | ||
113 | #else | ||
61 | spiConfig.cr1 = 0; | 114 | spiConfig.cr1 = 0; |
62 | 115 | ||
63 | if (lsbFirst) { | 116 | if (lsbFirst) { |
@@ -103,6 +156,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { | |||
103 | spiConfig.cr1 |= SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0; | 156 | spiConfig.cr1 |= SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0; |
104 | break; | 157 | break; |
105 | } | 158 | } |
159 | #endif | ||
106 | 160 | ||
107 | currentSlavePin = slavePin; | 161 | currentSlavePin = slavePin; |
108 | spiConfig.ssport = PAL_PORT(slavePin); | 162 | spiConfig.ssport = PAL_PORT(slavePin); |
diff --git a/drivers/chibios/spi_master.h b/drivers/chibios/spi_master.h index e93580e31..b5a6ef143 100644 --- a/drivers/chibios/spi_master.h +++ b/drivers/chibios/spi_master.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
22 | 22 | ||
23 | #include "gpio.h" | 23 | #include "gpio.h" |
24 | #include "chibios_config.h" | ||
24 | 25 | ||
25 | #ifndef SPI_DRIVER | 26 | #ifndef SPI_DRIVER |
26 | # define SPI_DRIVER SPID2 | 27 | # define SPI_DRIVER SPID2 |
@@ -31,7 +32,11 @@ | |||
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #ifndef SPI_SCK_PAL_MODE | 34 | #ifndef SPI_SCK_PAL_MODE |
34 | # define SPI_SCK_PAL_MODE 5 | 35 | # if defined(USE_GPIOV1) |
36 | # define SPI_SCK_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL | ||
37 | # else | ||
38 | # define SPI_SCK_PAL_MODE 5 | ||
39 | # endif | ||
35 | #endif | 40 | #endif |
36 | 41 | ||
37 | #ifndef SPI_MOSI_PIN | 42 | #ifndef SPI_MOSI_PIN |
@@ -39,7 +44,11 @@ | |||
39 | #endif | 44 | #endif |
40 | 45 | ||
41 | #ifndef SPI_MOSI_PAL_MODE | 46 | #ifndef SPI_MOSI_PAL_MODE |
42 | # define SPI_MOSI_PAL_MODE 5 | 47 | # if defined(USE_GPIOV1) |
48 | # define SPI_MOSI_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL | ||
49 | # else | ||
50 | # define SPI_MOSI_PAL_MODE 5 | ||
51 | # endif | ||
43 | #endif | 52 | #endif |
44 | 53 | ||
45 | #ifndef SPI_MISO_PIN | 54 | #ifndef SPI_MISO_PIN |
@@ -47,7 +56,11 @@ | |||
47 | #endif | 56 | #endif |
48 | 57 | ||
49 | #ifndef SPI_MISO_PAL_MODE | 58 | #ifndef SPI_MISO_PAL_MODE |
50 | # define SPI_MISO_PAL_MODE 5 | 59 | # if defined(USE_GPIOV1) |
60 | # define SPI_MISO_PAL_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL | ||
61 | # else | ||
62 | # define SPI_MISO_PAL_MODE 5 | ||
63 | # endif | ||
51 | #endif | 64 | #endif |
52 | 65 | ||
53 | typedef int16_t spi_status_t; | 66 | typedef int16_t spi_status_t; |
diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c index 4210f06f9..8e80ff544 100644 --- a/drivers/eeprom/eeprom_i2c.c +++ b/drivers/eeprom/eeprom_i2c.c | |||
@@ -16,6 +16,9 @@ | |||
16 | 16 | ||
17 | #include <stdint.h> | 17 | #include <stdint.h> |
18 | #include <string.h> | 18 | #include <string.h> |
19 | #if defined(EXTERNAL_EEPROM_WP_PIN) | ||
20 | # include "gpio.h" | ||
21 | #endif | ||
19 | 22 | ||
20 | /* | 23 | /* |
21 | Note that the implementations of eeprom_XXXX_YYYY on AVR are normally | 24 | Note that the implementations of eeprom_XXXX_YYYY on AVR are normally |
@@ -50,7 +53,14 @@ static inline void fill_target_address(uint8_t *buffer, const void *addr) { | |||
50 | } | 53 | } |
51 | } | 54 | } |
52 | 55 | ||
53 | void eeprom_driver_init(void) { i2c_init(); } | 56 | void eeprom_driver_init(void) { |
57 | i2c_init(); | ||
58 | #if defined(EXTERNAL_EEPROM_WP_PIN) | ||
59 | /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ | ||
60 | writePin(EXTERNAL_EEPROM_WP_PIN, 1); | ||
61 | setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); | ||
62 | #endif | ||
63 | } | ||
54 | 64 | ||
55 | void eeprom_driver_erase(void) { | 65 | void eeprom_driver_erase(void) { |
56 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) | 66 | #if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) |
@@ -89,6 +99,11 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
89 | uint8_t * read_buf = (uint8_t *)buf; | 99 | uint8_t * read_buf = (uint8_t *)buf; |
90 | uintptr_t target_addr = (uintptr_t)addr; | 100 | uintptr_t target_addr = (uintptr_t)addr; |
91 | 101 | ||
102 | #if defined(EXTERNAL_EEPROM_WP_PIN) | ||
103 | setPinOutput(EXTERNAL_EEPROM_WP_PIN); | ||
104 | writePin(EXTERNAL_EEPROM_WP_PIN, 0); | ||
105 | #endif | ||
106 | |||
92 | while (len > 0) { | 107 | while (len > 0) { |
93 | uintptr_t page_offset = target_addr % EXTERNAL_EEPROM_PAGE_SIZE; | 108 | uintptr_t page_offset = target_addr % EXTERNAL_EEPROM_PAGE_SIZE; |
94 | int write_length = EXTERNAL_EEPROM_PAGE_SIZE - page_offset; | 109 | int write_length = EXTERNAL_EEPROM_PAGE_SIZE - page_offset; |
@@ -116,4 +131,10 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { | |||
116 | target_addr += write_length; | 131 | target_addr += write_length; |
117 | len -= write_length; | 132 | len -= write_length; |
118 | } | 133 | } |
134 | |||
135 | #if defined(EXTERNAL_EEPROM_WP_PIN) | ||
136 | /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ | ||
137 | writePin(EXTERNAL_EEPROM_WP_PIN, 1); | ||
138 | setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); | ||
139 | #endif | ||
119 | } | 140 | } |
diff --git a/drivers/haptic/haptic.c b/drivers/haptic/haptic.c index de3f40052..3fab1be1a 100644 --- a/drivers/haptic/haptic.c +++ b/drivers/haptic/haptic.c | |||
@@ -291,6 +291,73 @@ void haptic_play(void) { | |||
291 | #endif | 291 | #endif |
292 | } | 292 | } |
293 | 293 | ||
294 | __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) { | ||
295 | switch(keycode) { | ||
296 | # ifdef NO_HAPTIC_MOD | ||
297 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | ||
298 | if (record->tap.count == 0) return false; | ||
299 | break; | ||
300 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: | ||
301 | if (record->tap.count != TAPPING_TOGGLE) return false; | ||
302 | break; | ||
303 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | ||
304 | if (record->tap.count == 0) return false; | ||
305 | break; | ||
306 | case KC_LCTRL ... KC_RGUI: | ||
307 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: | ||
308 | # endif | ||
309 | # ifdef NO_HAPTIC_FN | ||
310 | case KC_FN0 ... KC_FN31: | ||
311 | # endif | ||
312 | # ifdef NO_HAPTIC_ALPHA | ||
313 | case KC_A ... KC_Z: | ||
314 | # endif | ||
315 | # ifdef NO_HAPTIC_PUNCTUATION | ||
316 | case KC_ENTER: | ||
317 | case KC_ESCAPE: | ||
318 | case KC_BSPACE: | ||
319 | case KC_SPACE: | ||
320 | case KC_MINUS: | ||
321 | case KC_EQUAL: | ||
322 | case KC_LBRACKET: | ||
323 | case KC_RBRACKET: | ||
324 | case KC_BSLASH: | ||
325 | case KC_NONUS_HASH: | ||
326 | case KC_SCOLON: | ||
327 | case KC_QUOTE: | ||
328 | case KC_GRAVE: | ||
329 | case KC_COMMA: | ||
330 | case KC_SLASH: | ||
331 | case KC_DOT: | ||
332 | case KC_NONUS_BSLASH: | ||
333 | # endif | ||
334 | # ifdef NO_HAPTIC_LOCKKEYS | ||
335 | case KC_CAPSLOCK: | ||
336 | case KC_SCROLLLOCK: | ||
337 | case KC_NUMLOCK: | ||
338 | # endif | ||
339 | # ifdef NO_HAPTIC_NAV | ||
340 | case KC_PSCREEN: | ||
341 | case KC_PAUSE: | ||
342 | case KC_INSERT: | ||
343 | case KC_DELETE: | ||
344 | case KC_PGDOWN: | ||
345 | case KC_PGUP: | ||
346 | case KC_LEFT: | ||
347 | case KC_UP: | ||
348 | case KC_RIGHT: | ||
349 | case KC_DOWN: | ||
350 | case KC_END: | ||
351 | case KC_HOME: | ||
352 | # endif | ||
353 | # ifdef NO_HAPTIC_NUMERIC | ||
354 | case KC_1 ... KC_0: | ||
355 | # endif | ||
356 | return false; | ||
357 | } | ||
358 | return true; | ||
359 | } | ||
360 | |||
294 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { | 361 | bool process_haptic(uint16_t keycode, keyrecord_t *record) { |
295 | if (keycode == HPT_ON && record->event.pressed) { | 362 | if (keycode == HPT_ON && record->event.pressed) { |
296 | haptic_enable(); | 363 | haptic_enable(); |
@@ -335,12 +402,12 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { | |||
335 | if (haptic_config.enable) { | 402 | if (haptic_config.enable) { |
336 | if (record->event.pressed) { | 403 | if (record->event.pressed) { |
337 | // keypress | 404 | // keypress |
338 | if (haptic_config.feedback < 2) { | 405 | if (haptic_config.feedback < 2 && get_haptic_enabled_key(keycode, record)) { |
339 | haptic_play(); | 406 | haptic_play(); |
340 | } | 407 | } |
341 | } else { | 408 | } else { |
342 | // keyrelease | 409 | // keyrelease |
343 | if (haptic_config.feedback > 0) { | 410 | if (haptic_config.feedback > 0 && get_haptic_enabled_key(keycode, record)) { |
344 | haptic_play(); | 411 | haptic_play(); |
345 | } | 412 | } |
346 | } | 413 | } |
diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c new file mode 100644 index 000000000..49b13c00f --- /dev/null +++ b/drivers/lcd/st7565.c | |||
@@ -0,0 +1,496 @@ | |||
1 | /* | ||
2 | Copyright 2021 | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "st7565.h" | ||
19 | |||
20 | #include <string.h> | ||
21 | |||
22 | #include "keyboard.h" | ||
23 | #include "progmem.h" | ||
24 | #include "timer.h" | ||
25 | #include "wait.h" | ||
26 | |||
27 | #include ST7565_FONT_H | ||
28 | |||
29 | // Fundamental Commands | ||
30 | #define CONTRAST 0x81 | ||
31 | #define DISPLAY_ALL_ON 0xA5 | ||
32 | #define DISPLAY_ALL_ON_RESUME 0xA4 | ||
33 | #define NORMAL_DISPLAY 0xA6 | ||
34 | #define INVERT_DISPLAY 0xA7 | ||
35 | #define DISPLAY_ON 0xAF | ||
36 | #define DISPLAY_OFF 0xAE | ||
37 | #define NOP 0xE3 | ||
38 | |||
39 | // Addressing Setting Commands | ||
40 | #define PAM_SETCOLUMN_LSB 0x00 | ||
41 | #define PAM_SETCOLUMN_MSB 0x10 | ||
42 | #define PAM_PAGE_ADDR 0xB0 // 0xb0 -- 0xb7 | ||
43 | |||
44 | // Hardware Configuration Commands | ||
45 | #define DISPLAY_START_LINE 0x40 | ||
46 | #define SEGMENT_REMAP 0xA0 | ||
47 | #define SEGMENT_REMAP_INV 0xA1 | ||
48 | #define COM_SCAN_INC 0xC0 | ||
49 | #define COM_SCAN_DEC 0xC8 | ||
50 | #define LCD_BIAS_7 0xA3 | ||
51 | #define LCD_BIAS_9 0xA2 | ||
52 | #define RESISTOR_RATIO 0x20 | ||
53 | #define POWER_CONTROL 0x28 | ||
54 | |||
55 | // Misc defines | ||
56 | #ifndef ST7565_BLOCK_COUNT | ||
57 | # define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) | ||
58 | #endif | ||
59 | #ifndef ST7565_BLOCK_SIZE | ||
60 | # define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) | ||
61 | #endif | ||
62 | |||
63 | #define ST7565_ALL_BLOCKS_MASK (((((ST7565_BLOCK_TYPE)1 << (ST7565_BLOCK_COUNT - 1)) - 1) << 1) | 1) | ||
64 | |||
65 | #define HAS_FLAGS(bits, flags) ((bits & flags) == flags) | ||
66 | |||
67 | // Display buffer's is the same as the display memory layout | ||
68 | // this is so we don't end up with rounding errors with | ||
69 | // parts of the display unusable or don't get cleared correctly | ||
70 | // and also allows for drawing & inverting | ||
71 | uint8_t st7565_buffer[ST7565_MATRIX_SIZE]; | ||
72 | uint8_t * st7565_cursor; | ||
73 | ST7565_BLOCK_TYPE st7565_dirty = 0; | ||
74 | bool st7565_initialized = false; | ||
75 | bool st7565_active = false; | ||
76 | bool st7565_inverted = false; | ||
77 | display_rotation_t st7565_rotation = DISPLAY_ROTATION_0; | ||
78 | #if ST7565_TIMEOUT > 0 | ||
79 | uint32_t st7565_timeout; | ||
80 | #endif | ||
81 | #if ST7565_UPDATE_INTERVAL > 0 | ||
82 | uint16_t st7565_update_timeout; | ||
83 | #endif | ||
84 | |||
85 | // Flips the rendering bits for a character at the current cursor position | ||
86 | static void InvertCharacter(uint8_t *cursor) { | ||
87 | const uint8_t *end = cursor + ST7565_FONT_WIDTH; | ||
88 | while (cursor < end) { | ||
89 | *cursor = ~(*cursor); | ||
90 | cursor++; | ||
91 | } | ||
92 | } | ||
93 | |||
94 | bool st7565_init(display_rotation_t rotation) { | ||
95 | setPinOutput(ST7565_A0_PIN); | ||
96 | writePinHigh(ST7565_A0_PIN); | ||
97 | setPinOutput(ST7565_RST_PIN); | ||
98 | writePinHigh(ST7565_RST_PIN); | ||
99 | |||
100 | st7565_rotation = st7565_init_user(rotation); | ||
101 | |||
102 | spi_init(); | ||
103 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
104 | |||
105 | st7565_reset(); | ||
106 | |||
107 | st7565_send_cmd(LCD_BIAS_7); | ||
108 | if (!HAS_FLAGS(st7565_rotation, DISPLAY_ROTATION_180)) { | ||
109 | st7565_send_cmd(SEGMENT_REMAP); | ||
110 | st7565_send_cmd(COM_SCAN_DEC); | ||
111 | } else { | ||
112 | st7565_send_cmd(SEGMENT_REMAP_INV); | ||
113 | st7565_send_cmd(COM_SCAN_INC); | ||
114 | } | ||
115 | st7565_send_cmd(DISPLAY_START_LINE | 0x00); | ||
116 | st7565_send_cmd(CONTRAST); | ||
117 | st7565_send_cmd(ST7565_CONTRAST); | ||
118 | st7565_send_cmd(RESISTOR_RATIO | 0x01); | ||
119 | st7565_send_cmd(POWER_CONTROL | 0x04); | ||
120 | wait_ms(50); | ||
121 | st7565_send_cmd(POWER_CONTROL | 0x06); | ||
122 | wait_ms(50); | ||
123 | st7565_send_cmd(POWER_CONTROL | 0x07); | ||
124 | wait_ms(10); | ||
125 | st7565_send_cmd(DISPLAY_ON); | ||
126 | st7565_send_cmd(DISPLAY_ALL_ON_RESUME); | ||
127 | st7565_send_cmd(NORMAL_DISPLAY); | ||
128 | |||
129 | spi_stop(); | ||
130 | |||
131 | #if ST7565_TIMEOUT > 0 | ||
132 | st7565_timeout = timer_read32() + ST7565_TIMEOUT; | ||
133 | #endif | ||
134 | |||
135 | st7565_clear(); | ||
136 | st7565_initialized = true; | ||
137 | st7565_active = true; | ||
138 | return true; | ||
139 | } | ||
140 | |||
141 | __attribute__((weak)) display_rotation_t st7565_init_user(display_rotation_t rotation) { return rotation; } | ||
142 | |||
143 | void st7565_clear(void) { | ||
144 | memset(st7565_buffer, 0, sizeof(st7565_buffer)); | ||
145 | st7565_cursor = &st7565_buffer[0]; | ||
146 | st7565_dirty = ST7565_ALL_BLOCKS_MASK; | ||
147 | } | ||
148 | |||
149 | uint8_t crot(uint8_t a, int8_t n) { | ||
150 | const uint8_t mask = 0x7; | ||
151 | n &= mask; | ||
152 | return a << n | a >> (-n & mask); | ||
153 | } | ||
154 | |||
155 | void st7565_render(void) { | ||
156 | if (!st7565_initialized) { | ||
157 | return; | ||
158 | } | ||
159 | |||
160 | // Do we have work to do? | ||
161 | st7565_dirty &= ST7565_ALL_BLOCKS_MASK; | ||
162 | if (!st7565_dirty) { | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | // Find first dirty block | ||
167 | uint8_t update_start = 0; | ||
168 | while (!(st7565_dirty & ((ST7565_BLOCK_TYPE)1 << update_start))) { | ||
169 | ++update_start; | ||
170 | } | ||
171 | |||
172 | // Calculate commands to set memory addressing bounds. | ||
173 | uint8_t start_page = ST7565_BLOCK_SIZE * update_start / ST7565_DISPLAY_WIDTH; | ||
174 | uint8_t start_column = ST7565_BLOCK_SIZE * update_start % ST7565_DISPLAY_WIDTH; | ||
175 | // IC has 132 segment drivers, for panels with less width we need to offset the starting column | ||
176 | if (HAS_FLAGS(st7565_rotation, DISPLAY_ROTATION_180)) { | ||
177 | start_column += (132 - ST7565_DISPLAY_WIDTH); | ||
178 | } | ||
179 | |||
180 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
181 | |||
182 | st7565_send_cmd(PAM_PAGE_ADDR | start_page); | ||
183 | st7565_send_cmd(PAM_SETCOLUMN_LSB | ((ST7565_COLUMN_OFFSET + start_column) & 0x0f)); | ||
184 | st7565_send_cmd(PAM_SETCOLUMN_MSB | ((ST7565_COLUMN_OFFSET + start_column) >> 4 & 0x0f)); | ||
185 | |||
186 | st7565_send_data(&st7565_buffer[ST7565_BLOCK_SIZE * update_start], ST7565_BLOCK_SIZE); | ||
187 | |||
188 | // Turn on display if it is off | ||
189 | st7565_on(); | ||
190 | |||
191 | // Clear dirty flag | ||
192 | st7565_dirty &= ~((ST7565_BLOCK_TYPE)1 << update_start); | ||
193 | } | ||
194 | |||
195 | void st7565_set_cursor(uint8_t col, uint8_t line) { | ||
196 | uint16_t index = line * ST7565_DISPLAY_WIDTH + col * ST7565_FONT_WIDTH; | ||
197 | |||
198 | // Out of bounds? | ||
199 | if (index >= ST7565_MATRIX_SIZE) { | ||
200 | index = 0; | ||
201 | } | ||
202 | |||
203 | st7565_cursor = &st7565_buffer[index]; | ||
204 | } | ||
205 | |||
206 | void st7565_advance_page(bool clearPageRemainder) { | ||
207 | uint16_t index = st7565_cursor - &st7565_buffer[0]; | ||
208 | uint8_t remaining = ST7565_DISPLAY_WIDTH - (index % ST7565_DISPLAY_WIDTH); | ||
209 | |||
210 | if (clearPageRemainder) { | ||
211 | // Remaining Char count | ||
212 | remaining = remaining / ST7565_FONT_WIDTH; | ||
213 | |||
214 | // Write empty character until next line | ||
215 | while (remaining--) st7565_write_char(' ', false); | ||
216 | } else { | ||
217 | // Next page index out of bounds? | ||
218 | if (index + remaining >= ST7565_MATRIX_SIZE) { | ||
219 | index = 0; | ||
220 | remaining = 0; | ||
221 | } | ||
222 | |||
223 | st7565_cursor = &st7565_buffer[index + remaining]; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | void st7565_advance_char(void) { | ||
228 | uint16_t nextIndex = st7565_cursor - &st7565_buffer[0] + ST7565_FONT_WIDTH; | ||
229 | uint8_t remainingSpace = ST7565_DISPLAY_WIDTH - (nextIndex % ST7565_DISPLAY_WIDTH); | ||
230 | |||
231 | // Do we have enough space on the current line for the next character | ||
232 | if (remainingSpace < ST7565_FONT_WIDTH) { | ||
233 | nextIndex += remainingSpace; | ||
234 | } | ||
235 | |||
236 | // Did we go out of bounds | ||
237 | if (nextIndex >= ST7565_MATRIX_SIZE) { | ||
238 | nextIndex = 0; | ||
239 | } | ||
240 | |||
241 | // Update cursor position | ||
242 | st7565_cursor = &st7565_buffer[nextIndex]; | ||
243 | } | ||
244 | |||
245 | // Main handler that writes character data to the display buffer | ||
246 | void st7565_write_char(const char data, bool invert) { | ||
247 | // Advance to the next line if newline | ||
248 | if (data == '\n') { | ||
249 | // Old source wrote ' ' until end of line... | ||
250 | st7565_advance_page(true); | ||
251 | return; | ||
252 | } | ||
253 | |||
254 | if (data == '\r') { | ||
255 | st7565_advance_page(false); | ||
256 | return; | ||
257 | } | ||
258 | |||
259 | // copy the current render buffer to check for dirty after | ||
260 | static uint8_t st7565_temp_buffer[ST7565_FONT_WIDTH]; | ||
261 | memcpy(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH); | ||
262 | |||
263 | _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); | ||
264 | |||
265 | // set the reder buffer data | ||
266 | uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index | ||
267 | if (cast_data < ST7565_FONT_START || cast_data > ST7565_FONT_END) { | ||
268 | memset(st7565_cursor, 0x00, ST7565_FONT_WIDTH); | ||
269 | } else { | ||
270 | const uint8_t *glyph = &font[(cast_data - ST7565_FONT_START) * ST7565_FONT_WIDTH]; | ||
271 | memcpy_P(st7565_cursor, glyph, ST7565_FONT_WIDTH); | ||
272 | } | ||
273 | |||
274 | // Invert if needed | ||
275 | if (invert) { | ||
276 | InvertCharacter(st7565_cursor); | ||
277 | } | ||
278 | |||
279 | // Dirty check | ||
280 | if (memcmp(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH)) { | ||
281 | uint16_t index = st7565_cursor - &st7565_buffer[0]; | ||
282 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE)); | ||
283 | // Edgecase check if the written data spans the 2 chunks | ||
284 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << ((index + ST7565_FONT_WIDTH - 1) / ST7565_BLOCK_SIZE)); | ||
285 | } | ||
286 | |||
287 | // Finally move to the next char | ||
288 | st7565_advance_char(); | ||
289 | } | ||
290 | |||
291 | void st7565_write(const char *data, bool invert) { | ||
292 | const char *end = data + strlen(data); | ||
293 | while (data < end) { | ||
294 | st7565_write_char(*data, invert); | ||
295 | data++; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | void st7565_write_ln(const char *data, bool invert) { | ||
300 | st7565_write(data, invert); | ||
301 | st7565_advance_page(true); | ||
302 | } | ||
303 | |||
304 | void st7565_pan(bool left) { | ||
305 | uint16_t i = 0; | ||
306 | for (uint16_t y = 0; y < ST7565_DISPLAY_HEIGHT / 8; y++) { | ||
307 | if (left) { | ||
308 | for (uint16_t x = 0; x < ST7565_DISPLAY_WIDTH - 1; x++) { | ||
309 | i = y * ST7565_DISPLAY_WIDTH + x; | ||
310 | st7565_buffer[i] = st7565_buffer[i + 1]; | ||
311 | } | ||
312 | } else { | ||
313 | for (uint16_t x = ST7565_DISPLAY_WIDTH - 1; x > 0; x--) { | ||
314 | i = y * ST7565_DISPLAY_WIDTH + x; | ||
315 | st7565_buffer[i] = st7565_buffer[i - 1]; | ||
316 | } | ||
317 | } | ||
318 | } | ||
319 | st7565_dirty = ST7565_ALL_BLOCKS_MASK; | ||
320 | } | ||
321 | |||
322 | display_buffer_reader_t st7565_read_raw(uint16_t start_index) { | ||
323 | if (start_index > ST7565_MATRIX_SIZE) start_index = ST7565_MATRIX_SIZE; | ||
324 | display_buffer_reader_t ret_reader; | ||
325 | ret_reader.current_element = &st7565_buffer[start_index]; | ||
326 | ret_reader.remaining_element_count = ST7565_MATRIX_SIZE - start_index; | ||
327 | return ret_reader; | ||
328 | } | ||
329 | |||
330 | void st7565_write_raw_byte(const char data, uint16_t index) { | ||
331 | if (index > ST7565_MATRIX_SIZE) index = ST7565_MATRIX_SIZE; | ||
332 | if (st7565_buffer[index] == data) return; | ||
333 | st7565_buffer[index] = data; | ||
334 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE)); | ||
335 | } | ||
336 | |||
337 | void st7565_write_raw(const char *data, uint16_t size) { | ||
338 | uint16_t cursor_start_index = st7565_cursor - &st7565_buffer[0]; | ||
339 | if ((size + cursor_start_index) > ST7565_MATRIX_SIZE) size = ST7565_MATRIX_SIZE - cursor_start_index; | ||
340 | for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) { | ||
341 | uint8_t c = *data++; | ||
342 | if (st7565_buffer[i] == c) continue; | ||
343 | st7565_buffer[i] = c; | ||
344 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); | ||
345 | } | ||
346 | } | ||
347 | |||
348 | void st7565_write_pixel(uint8_t x, uint8_t y, bool on) { | ||
349 | if (x >= ST7565_DISPLAY_WIDTH) { | ||
350 | return; | ||
351 | } | ||
352 | uint16_t index = x + (y / 8) * ST7565_DISPLAY_WIDTH; | ||
353 | if (index >= ST7565_MATRIX_SIZE) { | ||
354 | return; | ||
355 | } | ||
356 | uint8_t data = st7565_buffer[index]; | ||
357 | if (on) { | ||
358 | data |= (1 << (y % 8)); | ||
359 | } else { | ||
360 | data &= ~(1 << (y % 8)); | ||
361 | } | ||
362 | if (st7565_buffer[index] != data) { | ||
363 | st7565_buffer[index] = data; | ||
364 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (index / ST7565_BLOCK_SIZE)); | ||
365 | } | ||
366 | } | ||
367 | |||
368 | #if defined(__AVR__) | ||
369 | void st7565_write_P(const char *data, bool invert) { | ||
370 | uint8_t c = pgm_read_byte(data); | ||
371 | while (c != 0) { | ||
372 | st7565_write_char(c, invert); | ||
373 | c = pgm_read_byte(++data); | ||
374 | } | ||
375 | } | ||
376 | |||
377 | void st7565_write_ln_P(const char *data, bool invert) { | ||
378 | st7565_write_P(data, invert); | ||
379 | st7565_advance_page(true); | ||
380 | } | ||
381 | |||
382 | void st7565_write_raw_P(const char *data, uint16_t size) { | ||
383 | uint16_t cursor_start_index = st7565_cursor - &st7565_buffer[0]; | ||
384 | if ((size + cursor_start_index) > ST7565_MATRIX_SIZE) size = ST7565_MATRIX_SIZE - cursor_start_index; | ||
385 | for (uint16_t i = cursor_start_index; i < cursor_start_index + size; i++) { | ||
386 | uint8_t c = pgm_read_byte(data++); | ||
387 | if (st7565_buffer[i] == c) continue; | ||
388 | st7565_buffer[i] = c; | ||
389 | st7565_dirty |= ((ST7565_BLOCK_TYPE)1 << (i / ST7565_BLOCK_SIZE)); | ||
390 | } | ||
391 | } | ||
392 | #endif // defined(__AVR__) | ||
393 | |||
394 | bool st7565_on(void) { | ||
395 | if (!st7565_initialized) { | ||
396 | return st7565_active; | ||
397 | } | ||
398 | |||
399 | #if ST7565_TIMEOUT > 0 | ||
400 | st7565_timeout = timer_read32() + ST7565_TIMEOUT; | ||
401 | #endif | ||
402 | |||
403 | if (!st7565_active) { | ||
404 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
405 | st7565_send_cmd(DISPLAY_ON); | ||
406 | spi_stop(); | ||
407 | st7565_active = true; | ||
408 | st7565_on_user(); | ||
409 | } | ||
410 | return st7565_active; | ||
411 | } | ||
412 | |||
413 | __attribute__((weak)) void st7565_on_user(void) {} | ||
414 | |||
415 | bool st7565_off(void) { | ||
416 | if (!st7565_initialized) { | ||
417 | return !st7565_active; | ||
418 | } | ||
419 | |||
420 | if (st7565_active) { | ||
421 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
422 | st7565_send_cmd(DISPLAY_OFF); | ||
423 | spi_stop(); | ||
424 | st7565_active = false; | ||
425 | st7565_off_user(); | ||
426 | } | ||
427 | return !st7565_active; | ||
428 | } | ||
429 | |||
430 | __attribute__((weak)) void st7565_off_user(void) {} | ||
431 | |||
432 | bool st7565_is_on(void) { return st7565_active; } | ||
433 | |||
434 | bool st7565_invert(bool invert) { | ||
435 | if (!st7565_initialized) { | ||
436 | return st7565_inverted; | ||
437 | } | ||
438 | |||
439 | if (invert != st7565_inverted) { | ||
440 | spi_start(ST7565_SS_PIN, false, 0, ST7565_SPI_CLK_DIVISOR); | ||
441 | st7565_send_cmd(invert ? INVERT_DISPLAY : NORMAL_DISPLAY); | ||
442 | spi_stop(); | ||
443 | st7565_inverted = invert; | ||
444 | } | ||
445 | return st7565_inverted; | ||
446 | } | ||
447 | |||
448 | uint8_t st7565_max_chars(void) { return ST7565_DISPLAY_WIDTH / ST7565_FONT_WIDTH; } | ||
449 | |||
450 | uint8_t st7565_max_lines(void) { return ST7565_DISPLAY_HEIGHT / ST7565_FONT_HEIGHT; } | ||
451 | |||
452 | void st7565_task(void) { | ||
453 | if (!st7565_initialized) { | ||
454 | return; | ||
455 | } | ||
456 | |||
457 | #if ST7565_UPDATE_INTERVAL > 0 | ||
458 | if (timer_elapsed(st7565_update_timeout) >= ST7565_UPDATE_INTERVAL) { | ||
459 | st7565_update_timeout = timer_read(); | ||
460 | st7565_set_cursor(0, 0); | ||
461 | st7565_task_user(); | ||
462 | } | ||
463 | #else | ||
464 | st7565_set_cursor(0, 0); | ||
465 | st7565_task_user(); | ||
466 | #endif | ||
467 | |||
468 | // Smart render system, no need to check for dirty | ||
469 | st7565_render(); | ||
470 | |||
471 | // Display timeout check | ||
472 | #if ST7565_TIMEOUT > 0 | ||
473 | if (st7565_active && timer_expired32(timer_read32(), st7565_timeout)) { | ||
474 | st7565_off(); | ||
475 | } | ||
476 | #endif | ||
477 | } | ||
478 | |||
479 | __attribute__((weak)) void st7565_task_user(void) {} | ||
480 | |||
481 | void st7565_reset(void) { | ||
482 | writePinLow(ST7565_RST_PIN); | ||
483 | wait_ms(20); | ||
484 | writePinHigh(ST7565_RST_PIN); | ||
485 | wait_ms(20); | ||
486 | } | ||
487 | |||
488 | spi_status_t st7565_send_cmd(uint8_t cmd) { | ||
489 | writePinLow(ST7565_A0_PIN); | ||
490 | return spi_write(cmd); | ||
491 | } | ||
492 | |||
493 | spi_status_t st7565_send_data(uint8_t *data, uint16_t length) { | ||
494 | writePinHigh(ST7565_A0_PIN); | ||
495 | return spi_transmit(data, length); | ||
496 | } | ||
diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h new file mode 100644 index 000000000..d453dbe6d --- /dev/null +++ b/drivers/lcd/st7565.h | |||
@@ -0,0 +1,219 @@ | |||
1 | /* | ||
2 | Copyright 2021 | ||
3 | |||
4 | This program is free software: you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation, either version 2 of the License, or | ||
7 | (at your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #pragma once | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include <stdbool.h> | ||
22 | |||
23 | #include "spi_master.h" | ||
24 | |||
25 | #ifndef ST7565_DISPLAY_WIDTH | ||
26 | # define ST7565_DISPLAY_WIDTH 128 | ||
27 | #endif | ||
28 | #ifndef ST7565_DISPLAY_HEIGHT | ||
29 | # define ST7565_DISPLAY_HEIGHT 32 | ||
30 | #endif | ||
31 | #ifndef ST7565_MATRIX_SIZE | ||
32 | # define ST7565_MATRIX_SIZE (ST7565_DISPLAY_HEIGHT / 8 * ST7565_DISPLAY_WIDTH) // 1024 (compile time mathed) | ||
33 | #endif | ||
34 | #ifndef ST7565_BLOCK_TYPE | ||
35 | # define ST7565_BLOCK_TYPE uint16_t | ||
36 | #endif | ||
37 | #ifndef ST7565_BLOCK_COUNT | ||
38 | # define ST7565_BLOCK_COUNT (sizeof(ST7565_BLOCK_TYPE) * 8) // 32 (compile time mathed) | ||
39 | #endif | ||
40 | #ifndef ST7565_BLOCK_SIZE | ||
41 | # define ST7565_BLOCK_SIZE (ST7565_MATRIX_SIZE / ST7565_BLOCK_COUNT) // 32 (compile time mathed) | ||
42 | #endif | ||
43 | |||
44 | // the column address corresponding to the first column in the display hardware | ||
45 | #if !defined(ST7565_COLUMN_OFFSET) | ||
46 | # define ST7565_COLUMN_OFFSET 0 | ||
47 | #endif | ||
48 | |||
49 | // spi clock divisor | ||
50 | #if !defined(ST7565_SPI_CLK_DIVISOR) | ||
51 | # define ST7565_SPI_CLK_DIVISOR 4 | ||
52 | #endif | ||
53 | |||
54 | // Custom font file to use | ||
55 | #if !defined(ST7565_FONT_H) | ||
56 | # define ST7565_FONT_H "glcdfont.c" | ||
57 | #endif | ||
58 | // unsigned char value of the first character in the font file | ||
59 | #if !defined(ST7565_FONT_START) | ||
60 | # define ST7565_FONT_START 0 | ||
61 | #endif | ||
62 | // unsigned char value of the last character in the font file | ||
63 | #if !defined(ST7565_FONT_END) | ||
64 | # define ST7565_FONT_END 223 | ||
65 | #endif | ||
66 | // Font render width | ||
67 | #if !defined(ST7565_FONT_WIDTH) | ||
68 | # define ST7565_FONT_WIDTH 6 | ||
69 | #endif | ||
70 | // Font render height | ||
71 | #if !defined(ST7565_FONT_HEIGHT) | ||
72 | # define ST7565_FONT_HEIGHT 8 | ||
73 | #endif | ||
74 | // Default contrast level | ||
75 | #if !defined(ST7565_CONTRAST) | ||
76 | # define ST7565_CONTRAST 32 | ||
77 | #endif | ||
78 | |||
79 | #if !defined(ST7565_TIMEOUT) | ||
80 | # if defined(ST7565_DISABLE_TIMEOUT) | ||
81 | # define ST7565_TIMEOUT 0 | ||
82 | # else | ||
83 | # define ST7565_TIMEOUT 60000 | ||
84 | # endif | ||
85 | #endif | ||
86 | |||
87 | #if !defined(ST7565_UPDATE_INTERVAL) && defined(SPLIT_KEYBOARD) | ||
88 | # define ST7565_UPDATE_INTERVAL 50 | ||
89 | #endif | ||
90 | |||
91 | typedef struct __attribute__((__packed__)) { | ||
92 | uint8_t *current_element; | ||
93 | uint16_t remaining_element_count; | ||
94 | } display_buffer_reader_t; | ||
95 | |||
96 | // Rotation enum values are flags | ||
97 | typedef enum { DISPLAY_ROTATION_0, DISPLAY_ROTATION_180 } display_rotation_t; | ||
98 | |||
99 | // Initialize the display, rotating the rendered output based on the define passed in. | ||
100 | // Returns true if the display was initialized successfully | ||
101 | bool st7565_init(display_rotation_t rotation); | ||
102 | |||
103 | // Called at the start of st7565_init, weak function overridable by the user | ||
104 | // rotation - the value passed into st7565_init | ||
105 | // Return new display_rotation_t if you want to override default rotation | ||
106 | display_rotation_t st7565_init_user(display_rotation_t rotation); | ||
107 | |||
108 | // Clears the display buffer, resets cursor position to 0, and sets the buffer to dirty for rendering | ||
109 | void st7565_clear(void); | ||
110 | |||
111 | // Renders the dirty chunks of the buffer to display | ||
112 | void st7565_render(void); | ||
113 | |||
114 | // Moves cursor to character position indicated by column and line, wraps if out of bounds | ||
115 | // Max column denoted by 'st7565_max_chars()' and max lines by 'st7565_max_lines()' functions | ||
116 | void st7565_set_cursor(uint8_t col, uint8_t line); | ||
117 | |||
118 | // Advances the cursor to the next page, writing ' ' if true | ||
119 | // Wraps to the begining when out of bounds | ||
120 | void st7565_advance_page(bool clearPageRemainder); | ||
121 | |||
122 | // Moves the cursor forward 1 character length | ||
123 | // Advance page if there is not enough room for the next character | ||
124 | // Wraps to the begining when out of bounds | ||
125 | void st7565_advance_char(void); | ||
126 | |||
127 | // Writes a single character to the buffer at current cursor position | ||
128 | // Advances the cursor while writing, inverts the pixels if true | ||
129 | // Main handler that writes character data to the display buffer | ||
130 | void st7565_write_char(const char data, bool invert); | ||
131 | |||
132 | // Writes a string to the buffer at current cursor position | ||
133 | // Advances the cursor while writing, inverts the pixels if true | ||
134 | void st7565_write(const char *data, bool invert); | ||
135 | |||
136 | // Writes a string to the buffer at current cursor position | ||
137 | // Advances the cursor while writing, inverts the pixels if true | ||
138 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | ||
139 | void st7565_write_ln(const char *data, bool invert); | ||
140 | |||
141 | // Pans the buffer to the right (or left by passing true) by moving contents of the buffer | ||
142 | // Useful for moving the screen in preparation for new drawing | ||
143 | void st7565_pan(bool left); | ||
144 | |||
145 | // Returns a pointer to the requested start index in the buffer plus remaining | ||
146 | // buffer length as struct | ||
147 | display_buffer_reader_t st7565_read_raw(uint16_t start_index); | ||
148 | |||
149 | // Writes a string to the buffer at current cursor position | ||
150 | void st7565_write_raw(const char *data, uint16_t size); | ||
151 | |||
152 | // Writes a single byte into the buffer at the specified index | ||
153 | void st7565_write_raw_byte(const char data, uint16_t index); | ||
154 | |||
155 | // Sets a specific pixel on or off | ||
156 | // Coordinates start at top-left and go right and down for positive x and y | ||
157 | void st7565_write_pixel(uint8_t x, uint8_t y, bool on); | ||
158 | |||
159 | #if defined(__AVR__) | ||
160 | // Writes a PROGMEM string to the buffer at current cursor position | ||
161 | // Advances the cursor while writing, inverts the pixels if true | ||
162 | // Remapped to call 'void st7565_write(const char *data, bool invert);' on ARM | ||
163 | void st7565_write_P(const char *data, bool invert); | ||
164 | |||
165 | // Writes a PROGMEM string to the buffer at current cursor position | ||
166 | // Advances the cursor while writing, inverts the pixels if true | ||
167 | // Advances the cursor to the next page, wiring ' ' to the remainder of the current page | ||
168 | // Remapped to call 'void st7565_write_ln(const char *data, bool invert);' on ARM | ||
169 | void st7565_write_ln_P(const char *data, bool invert); | ||
170 | |||
171 | // Writes a PROGMEM string to the buffer at current cursor position | ||
172 | void st7565_write_raw_P(const char *data, uint16_t size); | ||
173 | #else | ||
174 | # define st7565_write_P(data, invert) st7565_write(data, invert) | ||
175 | # define st7565_write_ln_P(data, invert) st7565_write_ln(data, invert) | ||
176 | # define st7565_write_raw_P(data, size) st7565_write_raw(data, size) | ||
177 | #endif // defined(__AVR__) | ||
178 | |||
179 | // Can be used to manually turn on the screen if it is off | ||
180 | // Returns true if the screen was on or turns on | ||
181 | bool st7565_on(void); | ||
182 | |||
183 | // Called when st7565_on() turns on the screen, weak function overridable by the user | ||
184 | // Not called if the screen is already on | ||
185 | void st7565_on_user(void); | ||
186 | |||
187 | // Can be used to manually turn off the screen if it is on | ||
188 | // Returns true if the screen was off or turns off | ||
189 | bool st7565_off(void); | ||
190 | |||
191 | // Called when st7565_off() turns off the screen, weak function overridable by the user | ||
192 | // Not called if the screen is already off | ||
193 | void st7565_off_user(void); | ||
194 | |||
195 | // Returns true if the screen is currently on, false if it is | ||
196 | // not | ||
197 | bool st7565_is_on(void); | ||
198 | |||
199 | // Basically it's st7565_render, but with timeout management and st7565_task_user calling! | ||
200 | void st7565_task(void); | ||
201 | |||
202 | // Called at the start of st7565_task, weak function overridable by the user | ||
203 | void st7565_task_user(void); | ||
204 | |||
205 | // Inverts the display | ||
206 | // Returns true if the screen was or is inverted | ||
207 | bool st7565_invert(bool invert); | ||
208 | |||
209 | // Returns the maximum number of characters that will fit on a line | ||
210 | uint8_t st7565_max_chars(void); | ||
211 | |||
212 | // Returns the maximum number of lines that will fit on the display | ||
213 | uint8_t st7565_max_lines(void); | ||
214 | |||
215 | void st7565_reset(void); | ||
216 | |||
217 | spi_status_t st7565_send_cmd(uint8_t cmd); | ||
218 | |||
219 | spi_status_t st7565_send_data(uint8_t *data, uint16_t length); | ||
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 8e5ed5f07..7d4197890 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c | |||
@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
34 | #define DISPLAY_ALL_ON 0xA5 | 34 | #define DISPLAY_ALL_ON 0xA5 |
35 | #define DISPLAY_ALL_ON_RESUME 0xA4 | 35 | #define DISPLAY_ALL_ON_RESUME 0xA4 |
36 | #define NORMAL_DISPLAY 0xA6 | 36 | #define NORMAL_DISPLAY 0xA6 |
37 | #define INVERT_DISPLAY 0xA7 | ||
37 | #define DISPLAY_ON 0xAF | 38 | #define DISPLAY_ON 0xAF |
38 | #define DISPLAY_OFF 0xAE | 39 | #define DISPLAY_OFF 0xAE |
39 | #define NOP 0xE3 | 40 | #define NOP 0xE3 |
@@ -114,6 +115,7 @@ OLED_BLOCK_TYPE oled_dirty = 0; | |||
114 | bool oled_initialized = false; | 115 | bool oled_initialized = false; |
115 | bool oled_active = false; | 116 | bool oled_active = false; |
116 | bool oled_scrolling = false; | 117 | bool oled_scrolling = false; |
118 | bool oled_inverted = false; | ||
117 | uint8_t oled_brightness = OLED_BRIGHTNESS; | 119 | uint8_t oled_brightness = OLED_BRIGHTNESS; |
118 | oled_rotation_t oled_rotation = 0; | 120 | oled_rotation_t oled_rotation = 0; |
119 | uint8_t oled_rotation_width = 0; | 121 | uint8_t oled_rotation_width = 0; |
@@ -690,6 +692,30 @@ bool oled_scroll_off(void) { | |||
690 | return !oled_scrolling; | 692 | return !oled_scrolling; |
691 | } | 693 | } |
692 | 694 | ||
695 | bool oled_invert(bool invert) { | ||
696 | if (!oled_initialized) { | ||
697 | return oled_inverted; | ||
698 | } | ||
699 | |||
700 | if (invert && !oled_inverted) { | ||
701 | static const uint8_t PROGMEM display_inverted[] = {I2C_CMD, INVERT_DISPLAY}; | ||
702 | if (I2C_TRANSMIT_P(display_inverted) != I2C_STATUS_SUCCESS) { | ||
703 | print("oled_invert cmd failed\n"); | ||
704 | return oled_inverted; | ||
705 | } | ||
706 | oled_inverted = true; | ||
707 | } else if (!invert && oled_inverted) { | ||
708 | static const uint8_t PROGMEM display_normal[] = {I2C_CMD, NORMAL_DISPLAY}; | ||
709 | if (I2C_TRANSMIT_P(display_normal) != I2C_STATUS_SUCCESS) { | ||
710 | print("oled_invert cmd failed\n"); | ||
711 | return oled_inverted; | ||
712 | } | ||
713 | oled_inverted = false; | ||
714 | } | ||
715 | |||
716 | return oled_inverted; | ||
717 | } | ||
718 | |||
693 | uint8_t oled_max_chars(void) { | 719 | uint8_t oled_max_chars(void) { |
694 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { | 720 | if (!HAS_FLAGS(oled_rotation, OLED_ROTATION_90)) { |
695 | return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; | 721 | return OLED_DISPLAY_WIDTH / OLED_FONT_WIDTH; |
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index a6b85f37e..fc68f0ec9 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
@@ -313,6 +313,10 @@ bool oled_scroll_left(void); | |||
313 | // Returns true if the screen was not scrolling or stops scrolling | 313 | // Returns true if the screen was not scrolling or stops scrolling |
314 | bool oled_scroll_off(void); | 314 | bool oled_scroll_off(void); |
315 | 315 | ||
316 | // Inverts the display | ||
317 | // Returns true if the screen was or is inverted | ||
318 | bool oled_invert(bool invert); | ||
319 | |||
316 | // Returns the maximum number of characters that will fit on a line | 320 | // Returns the maximum number of characters that will fit on a line |
317 | uint8_t oled_max_chars(void); | 321 | uint8_t oled_max_chars(void); |
318 | 322 | ||
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c new file mode 100644 index 000000000..e7273977d --- /dev/null +++ b/drivers/sensors/adns5050.c | |||
@@ -0,0 +1,193 @@ | |||
1 | /* Copyright 2021 Colin Lam (Ploopy Corporation) | ||
2 | * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
3 | * Copyright 2019 Sunjun Kim | ||
4 | * Copyright 2019 Hiroyuki Okada | ||
5 | * | ||
6 | * This program is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation, either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include "adns5050.h" | ||
22 | #include "wait.h" | ||
23 | #include "debug.h" | ||
24 | #include "print.h" | ||
25 | #include "gpio.h" | ||
26 | |||
27 | #ifndef OPTIC_ROTATED | ||
28 | # define OPTIC_ROTATED false | ||
29 | #endif | ||
30 | |||
31 | // Definitions for the ADNS serial line. | ||
32 | #ifndef ADNS_SCLK_PIN | ||
33 | # define ADNS_SCLK_PIN B7 | ||
34 | #endif | ||
35 | |||
36 | #ifndef ADNS_SDIO_PIN | ||
37 | # define ADNS_SDIO_PIN C6 | ||
38 | #endif | ||
39 | |||
40 | #ifndef ADNS_CS_PIN | ||
41 | # define ADNS_CS_PIN B4 | ||
42 | #endif | ||
43 | |||
44 | #ifdef CONSOLE_ENABLE | ||
45 | void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } | ||
46 | #endif | ||
47 | |||
48 | // Initialize the ADNS serial pins. | ||
49 | void adns_init(void) { | ||
50 | setPinOutput(ADNS_SCLK_PIN); | ||
51 | setPinOutput(ADNS_SDIO_PIN); | ||
52 | setPinOutput(ADNS_CS_PIN); | ||
53 | } | ||
54 | |||
55 | // Perform a synchronization with the ADNS. | ||
56 | // Just as with the serial protocol, this is used by the slave to send a | ||
57 | // synchronization signal to the master. | ||
58 | void adns_sync(void) { | ||
59 | writePinLow(ADNS_CS_PIN); | ||
60 | wait_us(1); | ||
61 | writePinHigh(ADNS_CS_PIN); | ||
62 | } | ||
63 | |||
64 | void adns_cs_select(void) { | ||
65 | writePinLow(ADNS_CS_PIN); | ||
66 | } | ||
67 | |||
68 | void adns_cs_deselect(void) { | ||
69 | writePinHigh(ADNS_CS_PIN); | ||
70 | } | ||
71 | |||
72 | uint8_t adns_serial_read(void) { | ||
73 | setPinInput(ADNS_SDIO_PIN); | ||
74 | uint8_t byte = 0; | ||
75 | |||
76 | for (uint8_t i = 0; i < 8; ++i) { | ||
77 | writePinLow(ADNS_SCLK_PIN); | ||
78 | wait_us(1); | ||
79 | |||
80 | byte = (byte << 1) | readPin(ADNS_SDIO_PIN); | ||
81 | |||
82 | writePinHigh(ADNS_SCLK_PIN); | ||
83 | wait_us(1); | ||
84 | } | ||
85 | |||
86 | return byte; | ||
87 | } | ||
88 | |||
89 | void adns_serial_write(uint8_t data) { | ||
90 | setPinOutput(ADNS_SDIO_PIN); | ||
91 | |||
92 | for (int8_t b = 7; b >= 0; b--) { | ||
93 | writePinLow(ADNS_SCLK_PIN); | ||
94 | |||
95 | if (data & (1 << b)) | ||
96 | writePinHigh(ADNS_SDIO_PIN); | ||
97 | else | ||
98 | writePinLow(ADNS_SDIO_PIN); | ||
99 | |||
100 | wait_us(2); | ||
101 | |||
102 | writePinHigh(ADNS_SCLK_PIN); | ||
103 | } | ||
104 | |||
105 | // tSWR. See page 15 of the ADNS spec sheet. | ||
106 | // Technically, this is only necessary if the next operation is an SDIO | ||
107 | // read. This is not guaranteed to be the case, but we're being lazy. | ||
108 | wait_us(4); | ||
109 | |||
110 | // Note that tSWW is never necessary. All write operations require at | ||
111 | // least 32us, which exceeds tSWW, so there's never a need to wait for it. | ||
112 | } | ||
113 | |||
114 | // Read a byte of data from a register on the ADNS. | ||
115 | // Don't forget to use the register map (as defined in the header file). | ||
116 | uint8_t adns_read_reg(uint8_t reg_addr) { | ||
117 | adns_cs_select(); | ||
118 | |||
119 | adns_serial_write(reg_addr); | ||
120 | |||
121 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is | ||
122 | // already included in adns_serial_write(), so we're good. | ||
123 | // See page 10 and 15 of the ADNS spec sheet. | ||
124 | //wait_us(4); | ||
125 | |||
126 | uint8_t byte = adns_serial_read(); | ||
127 | |||
128 | // tSRW & tSRR. See page 15 of the ADNS spec sheet. | ||
129 | // Technically, this is only necessary if the next operation is an SDIO | ||
130 | // read or write. This is not guaranteed to be the case. | ||
131 | // Honestly, this wait could probably be removed. | ||
132 | wait_us(1); | ||
133 | |||
134 | adns_cs_deselect(); | ||
135 | |||
136 | return byte; | ||
137 | } | ||
138 | |||
139 | void adns_write_reg(uint8_t reg_addr, uint8_t data) { | ||
140 | adns_cs_select(); | ||
141 | adns_serial_write( 0b10000000 | reg_addr ); | ||
142 | adns_serial_write(data); | ||
143 | adns_cs_deselect(); | ||
144 | } | ||
145 | |||
146 | report_adns_t adns_read_burst(void) { | ||
147 | adns_cs_select(); | ||
148 | |||
149 | report_adns_t data; | ||
150 | data.dx = 0; | ||
151 | data.dy = 0; | ||
152 | |||
153 | adns_serial_write(REG_MOTION_BURST); | ||
154 | |||
155 | // We don't need a minimum tSRAD here. That's because a 4ms wait time is | ||
156 | // already included in adns_serial_write(), so we're good. | ||
157 | // See page 10 and 15 of the ADNS spec sheet. | ||
158 | //wait_us(4); | ||
159 | |||
160 | uint8_t x = adns_serial_read(); | ||
161 | uint8_t y = adns_serial_read(); | ||
162 | |||
163 | // Burst mode returns a bunch of other shit that we don't really need. | ||
164 | // Setting CS to high ends burst mode early. | ||
165 | adns_cs_deselect(); | ||
166 | |||
167 | data.dx = convert_twoscomp(x); | ||
168 | data.dy = convert_twoscomp(y); | ||
169 | |||
170 | return data; | ||
171 | } | ||
172 | |||
173 | // Convert a two's complement byte from an unsigned data type into a signed | ||
174 | // data type. | ||
175 | int8_t convert_twoscomp(uint8_t data) { | ||
176 | if ((data & 0x80) == 0x80) | ||
177 | return -128 + (data & 0x7F); | ||
178 | else | ||
179 | return data; | ||
180 | } | ||
181 | |||
182 | // Don't forget to use the definitions for CPI in the header file. | ||
183 | void adns_set_cpi(uint8_t cpi) { | ||
184 | adns_write_reg(REG_MOUSE_CONTROL2, cpi); | ||
185 | } | ||
186 | |||
187 | bool adns_check_signature(void) { | ||
188 | uint8_t pid = adns_read_reg(REG_PRODUCT_ID); | ||
189 | uint8_t rid = adns_read_reg(REG_REVISION_ID); | ||
190 | uint8_t pid2 = adns_read_reg(REG_PRODUCT_ID2); | ||
191 | |||
192 | return (pid == 0x12 && rid == 0x01 && pid2 == 0x26); | ||
193 | } | ||
diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h new file mode 100644 index 000000000..ff8e8f78e --- /dev/null +++ b/drivers/sensors/adns5050.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /* Copyright 2021 Colin Lam (Ploopy Corporation) | ||
2 | * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
3 | * Copyright 2019 Sunjun Kim | ||
4 | * Copyright 2019 Hiroyuki Okada | ||
5 | * | ||
6 | * This program is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation, either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #pragma once | ||
21 | |||
22 | #include <stdbool.h> | ||
23 | |||
24 | // Registers | ||
25 | #define REG_PRODUCT_ID 0x00 | ||
26 | #define REG_REVISION_ID 0x01 | ||
27 | #define REG_MOTION 0x02 | ||
28 | #define REG_DELTA_X 0x03 | ||
29 | #define REG_DELTA_Y 0x04 | ||
30 | #define REG_SQUAL 0x05 | ||
31 | #define REG_SHUTTER_UPPER 0x06 | ||
32 | #define REG_SHUTTER_LOWER 0x07 | ||
33 | #define REG_MAXIMUM_PIXEL 0x08 | ||
34 | #define REG_PIXEL_SUM 0x09 | ||
35 | #define REG_MINIMUM_PIXEL 0x0a | ||
36 | #define REG_PIXEL_GRAB 0x0b | ||
37 | #define REG_MOUSE_CONTROL 0x0d | ||
38 | #define REG_MOUSE_CONTROL2 0x19 | ||
39 | #define REG_LED_DC_MODE 0x22 | ||
40 | #define REG_CHIP_RESET 0x3a | ||
41 | #define REG_PRODUCT_ID2 0x3e | ||
42 | #define REG_INV_REV_ID 0x3f | ||
43 | #define REG_MOTION_BURST 0x63 | ||
44 | |||
45 | // CPI values | ||
46 | #define CPI125 0x11 | ||
47 | #define CPI250 0x12 | ||
48 | #define CPI375 0x13 | ||
49 | #define CPI500 0x14 | ||
50 | #define CPI625 0x15 | ||
51 | #define CPI750 0x16 | ||
52 | #define CPI875 0x17 | ||
53 | #define CPI1000 0x18 | ||
54 | #define CPI1125 0x19 | ||
55 | #define CPI1250 0x1a | ||
56 | #define CPI1375 0x1b | ||
57 | |||
58 | #ifdef CONSOLE_ENABLE | ||
59 | void print_byte(uint8_t byte); | ||
60 | #endif | ||
61 | |||
62 | typedef struct { | ||
63 | int8_t dx; | ||
64 | int8_t dy; | ||
65 | } report_adns_t; | ||
66 | |||
67 | // A bunch of functions to implement the ADNS5050-specific serial protocol. | ||
68 | // Note that the "serial.h" driver is insufficient, because it does not | ||
69 | // manually manipulate a serial clock signal. | ||
70 | void adns_init(void); | ||
71 | void adns_sync(void); | ||
72 | uint8_t adns_serial_read(void); | ||
73 | void adns_serial_write(uint8_t data); | ||
74 | uint8_t adns_read_reg(uint8_t reg_addr); | ||
75 | void adns_write_reg(uint8_t reg_addr, uint8_t data); | ||
76 | report_adns_t adns_read_burst(void); | ||
77 | int8_t convert_twoscomp(uint8_t data); | ||
78 | void adns_set_cpi(uint8_t cpi); | ||
79 | bool adns_check_signature(void); | ||
diff --git a/drivers/sensors/adns9800.c b/drivers/sensors/adns9800.c new file mode 100644 index 000000000..36213179f --- /dev/null +++ b/drivers/sensors/adns9800.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /* Copyright 2020 Alexander Tulloh | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include "spi_master.h" | ||
18 | #include "quantum.h" | ||
19 | #include "adns9800_srom_A6.h" | ||
20 | #include "adns9800.h" | ||
21 | |||
22 | // registers | ||
23 | #define REG_Product_ID 0x00 | ||
24 | #define REG_Revision_ID 0x01 | ||
25 | #define REG_Motion 0x02 | ||
26 | #define REG_Delta_X_L 0x03 | ||
27 | #define REG_Delta_X_H 0x04 | ||
28 | #define REG_Delta_Y_L 0x05 | ||
29 | #define REG_Delta_Y_H 0x06 | ||
30 | #define REG_SQUAL 0x07 | ||
31 | #define REG_Pixel_Sum 0x08 | ||
32 | #define REG_Maximum_Pixel 0x09 | ||
33 | #define REG_Minimum_Pixel 0x0a | ||
34 | #define REG_Shutter_Lower 0x0b | ||
35 | #define REG_Shutter_Upper 0x0c | ||
36 | #define REG_Frame_Period_Lower 0x0d | ||
37 | #define REG_Frame_Period_Upper 0x0e | ||
38 | #define REG_Configuration_I 0x0f | ||
39 | #define REG_Configuration_II 0x10 | ||
40 | #define REG_Frame_Capture 0x12 | ||
41 | #define REG_SROM_Enable 0x13 | ||
42 | #define REG_Run_Downshift 0x14 | ||
43 | #define REG_Rest1_Rate 0x15 | ||
44 | #define REG_Rest1_Downshift 0x16 | ||
45 | #define REG_Rest2_Rate 0x17 | ||
46 | #define REG_Rest2_Downshift 0x18 | ||
47 | #define REG_Rest3_Rate 0x19 | ||
48 | #define REG_Frame_Period_Max_Bound_Lower 0x1a | ||
49 | #define REG_Frame_Period_Max_Bound_Upper 0x1b | ||
50 | #define REG_Frame_Period_Min_Bound_Lower 0x1c | ||
51 | #define REG_Frame_Period_Min_Bound_Upper 0x1d | ||
52 | #define REG_Shutter_Max_Bound_Lower 0x1e | ||
53 | #define REG_Shutter_Max_Bound_Upper 0x1f | ||
54 | #define REG_LASER_CTRL0 0x20 | ||
55 | #define REG_Observation 0x24 | ||
56 | #define REG_Data_Out_Lower 0x25 | ||
57 | #define REG_Data_Out_Upper 0x26 | ||
58 | #define REG_SROM_ID 0x2a | ||
59 | #define REG_Lift_Detection_Thr 0x2e | ||
60 | #define REG_Configuration_V 0x2f | ||
61 | #define REG_Configuration_IV 0x39 | ||
62 | #define REG_Power_Up_Reset 0x3a | ||
63 | #define REG_Shutdown 0x3b | ||
64 | #define REG_Inverse_Product_ID 0x3f | ||
65 | #define REG_Motion_Burst 0x50 | ||
66 | #define REG_SROM_Load_Burst 0x62 | ||
67 | #define REG_Pixel_Burst 0x64 | ||
68 | |||
69 | #define ADNS_CLOCK_SPEED 2000000 | ||
70 | #define MIN_CPI 200 | ||
71 | #define MAX_CPI 8200 | ||
72 | #define CPI_STEP 200 | ||
73 | #define CLAMP_CPI(value) value < MIN_CPI ? MIN_CPI : value > MAX_CPI ? MAX_CPI : value | ||
74 | #define SPI_MODE 3 | ||
75 | #define SPI_DIVISOR (F_CPU / ADNS_CLOCK_SPEED) | ||
76 | #define US_BETWEEN_WRITES 120 | ||
77 | #define US_BETWEEN_READS 20 | ||
78 | #define US_BEFORE_MOTION 100 | ||
79 | #define MSB1 0x80 | ||
80 | |||
81 | extern const uint16_t adns_firmware_length; | ||
82 | extern const uint8_t adns_firmware_data[]; | ||
83 | |||
84 | void adns_spi_start(void){ | ||
85 | spi_start(SPI_SS_PIN, false, SPI_MODE, SPI_DIVISOR); | ||
86 | } | ||
87 | |||
88 | void adns_write(uint8_t reg_addr, uint8_t data){ | ||
89 | |||
90 | adns_spi_start(); | ||
91 | spi_write(reg_addr | MSB1); | ||
92 | spi_write(data); | ||
93 | spi_stop(); | ||
94 | wait_us(US_BETWEEN_WRITES); | ||
95 | } | ||
96 | |||
97 | uint8_t adns_read(uint8_t reg_addr){ | ||
98 | |||
99 | adns_spi_start(); | ||
100 | spi_write(reg_addr & 0x7f ); | ||
101 | uint8_t data = spi_read(); | ||
102 | spi_stop(); | ||
103 | wait_us(US_BETWEEN_READS); | ||
104 | |||
105 | return data; | ||
106 | } | ||
107 | |||
108 | void adns_init() { | ||
109 | |||
110 | setPinOutput(SPI_SS_PIN); | ||
111 | |||
112 | spi_init(); | ||
113 | |||
114 | // reboot | ||
115 | adns_write(REG_Power_Up_Reset, 0x5a); | ||
116 | wait_ms(50); | ||
117 | |||
118 | // read registers and discard | ||
119 | adns_read(REG_Motion); | ||
120 | adns_read(REG_Delta_X_L); | ||
121 | adns_read(REG_Delta_X_H); | ||
122 | adns_read(REG_Delta_Y_L); | ||
123 | adns_read(REG_Delta_Y_H); | ||
124 | |||
125 | // upload firmware | ||
126 | |||
127 | // 3k firmware mode | ||
128 | adns_write(REG_Configuration_IV, 0x02); | ||
129 | |||
130 | // enable initialisation | ||
131 | adns_write(REG_SROM_Enable, 0x1d); | ||
132 | |||
133 | // wait a frame | ||
134 | wait_ms(10); | ||
135 | |||
136 | // start SROM download | ||
137 | adns_write(REG_SROM_Enable, 0x18); | ||
138 | |||
139 | // write the SROM file | ||
140 | |||
141 | adns_spi_start(); | ||
142 | |||
143 | spi_write(REG_SROM_Load_Burst | 0x80); | ||
144 | wait_us(15); | ||
145 | |||
146 | // send all bytes of the firmware | ||
147 | unsigned char c; | ||
148 | for(int i = 0; i < adns_firmware_length; i++){ | ||
149 | c = (unsigned char)pgm_read_byte(adns_firmware_data + i); | ||
150 | spi_write(c); | ||
151 | wait_us(15); | ||
152 | } | ||
153 | |||
154 | spi_stop(); | ||
155 | |||
156 | wait_ms(10); | ||
157 | |||
158 | // enable laser | ||
159 | uint8_t laser_ctrl0 = adns_read(REG_LASER_CTRL0); | ||
160 | adns_write(REG_LASER_CTRL0, laser_ctrl0 & 0xf0); | ||
161 | } | ||
162 | |||
163 | config_adns_t adns_get_config(void) { | ||
164 | uint8_t config_1 = adns_read(REG_Configuration_I); | ||
165 | return (config_adns_t){ (config_1 & 0xFF) * CPI_STEP }; | ||
166 | } | ||
167 | |||
168 | void adns_set_config(config_adns_t config) { | ||
169 | uint8_t config_1 = (CLAMP_CPI(config.cpi) / CPI_STEP) & 0xFF; | ||
170 | adns_write(REG_Configuration_I, config_1); | ||
171 | } | ||
172 | |||
173 | static int16_t convertDeltaToInt(uint8_t high, uint8_t low){ | ||
174 | |||
175 | // join bytes into twos compliment | ||
176 | uint16_t twos_comp = (high << 8) | low; | ||
177 | |||
178 | // convert twos comp to int | ||
179 | if (twos_comp & 0x8000) | ||
180 | return -1 * (~twos_comp + 1); | ||
181 | |||
182 | return twos_comp; | ||
183 | } | ||
184 | |||
185 | report_adns_t adns_get_report(void) { | ||
186 | |||
187 | report_adns_t report = {0, 0}; | ||
188 | |||
189 | adns_spi_start(); | ||
190 | |||
191 | // start burst mode | ||
192 | spi_write(REG_Motion_Burst & 0x7f); | ||
193 | |||
194 | wait_us(US_BEFORE_MOTION); | ||
195 | |||
196 | uint8_t motion = spi_read(); | ||
197 | |||
198 | if(motion & 0x80) { | ||
199 | |||
200 | // clear observation register | ||
201 | spi_read(); | ||
202 | |||
203 | // delta registers | ||
204 | uint8_t delta_x_l = spi_read(); | ||
205 | uint8_t delta_x_h = spi_read(); | ||
206 | uint8_t delta_y_l = spi_read(); | ||
207 | uint8_t delta_y_h = spi_read(); | ||
208 | |||
209 | report.x = convertDeltaToInt(delta_x_h, delta_x_l); | ||
210 | report.y = convertDeltaToInt(delta_y_h, delta_y_l); | ||
211 | } | ||
212 | |||
213 | // clear residual motion | ||
214 | spi_write(REG_Motion & 0x7f); | ||
215 | |||
216 | spi_stop(); | ||
217 | |||
218 | return report; | ||
219 | } | ||
diff --git a/drivers/sensors/adns9800.h b/drivers/sensors/adns9800.h new file mode 100644 index 000000000..2f50b8f1b --- /dev/null +++ b/drivers/sensors/adns9800.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* Copyright 2020 Alexander Tulloh | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include <stdint.h> | ||
20 | |||
21 | typedef struct { | ||
22 | /* 200 - 8200 CPI supported */ | ||
23 | uint16_t cpi; | ||
24 | } config_adns_t; | ||
25 | |||
26 | typedef struct { | ||
27 | int16_t x; | ||
28 | int16_t y; | ||
29 | } report_adns_t; | ||
30 | |||
31 | void adns_init(void); | ||
32 | config_adns_t adns_get_config(void); | ||
33 | void adns_set_config(config_adns_t); | ||
34 | /* Reads and clears the current delta values on the ADNS sensor */ | ||
35 | report_adns_t adns_get_report(void); | ||
diff --git a/drivers/sensors/adns9800_srom_A6.h b/drivers/sensors/adns9800_srom_A6.h new file mode 100644 index 000000000..f5b3abeb6 --- /dev/null +++ b/drivers/sensors/adns9800_srom_A6.h | |||
@@ -0,0 +1,3078 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include "progmem.h" | ||
4 | |||
5 | const uint16_t adns_firmware_length = 3070; | ||
6 | |||
7 | const uint8_t adns_firmware_data[] PROGMEM = { | ||
8 | 0x03, | ||
9 | 0xa6, | ||
10 | 0x68, | ||
11 | 0x1e, | ||
12 | 0x7d, | ||
13 | 0x10, | ||
14 | 0x7e, | ||
15 | 0x7e, | ||
16 | 0x5f, | ||
17 | 0x1c, | ||
18 | 0xb8, | ||
19 | 0xf2, | ||
20 | 0x47, | ||
21 | 0x0c, | ||
22 | 0x7b, | ||
23 | 0x74, | ||
24 | 0x4b, | ||
25 | 0x14, | ||
26 | 0x8b, | ||
27 | 0x75, | ||
28 | 0x66, | ||
29 | 0x51, | ||
30 | 0x0b, | ||
31 | 0x8c, | ||
32 | 0x76, | ||
33 | 0x74, | ||
34 | 0x4b, | ||
35 | 0x14, | ||
36 | 0xaa, | ||
37 | 0xd6, | ||
38 | 0x0f, | ||
39 | 0x9c, | ||
40 | 0xba, | ||
41 | 0xf6, | ||
42 | 0x6e, | ||
43 | 0x3f, | ||
44 | 0xdd, | ||
45 | 0x38, | ||
46 | 0xd5, | ||
47 | 0x02, | ||
48 | 0x80, | ||
49 | 0x9b, | ||
50 | 0x82, | ||
51 | 0x6d, | ||
52 | 0x58, | ||
53 | 0x13, | ||
54 | 0xa4, | ||
55 | 0xab, | ||
56 | 0xb5, | ||
57 | 0xc9, | ||
58 | 0x10, | ||
59 | 0xa2, | ||
60 | 0xc6, | ||
61 | 0x0a, | ||
62 | 0x7f, | ||
63 | 0x5d, | ||
64 | 0x19, | ||
65 | 0x91, | ||
66 | 0xa0, | ||
67 | 0xa3, | ||
68 | 0xce, | ||
69 | 0xeb, | ||
70 | 0x3e, | ||
71 | 0xc9, | ||
72 | 0xf1, | ||
73 | 0x60, | ||
74 | 0x42, | ||
75 | 0xe7, | ||
76 | 0x4c, | ||
77 | 0xfb, | ||
78 | 0x74, | ||
79 | 0x6a, | ||
80 | 0x56, | ||
81 | 0x2e, | ||
82 | 0xbf, | ||
83 | 0xdd, | ||
84 | 0x38, | ||
85 | 0xd3, | ||
86 | 0x05, | ||
87 | 0x88, | ||
88 | 0x92, | ||
89 | 0xa6, | ||
90 | 0xce, | ||
91 | 0xff, | ||
92 | 0x5d, | ||
93 | 0x38, | ||
94 | 0xd1, | ||
95 | 0xcf, | ||
96 | 0xef, | ||
97 | 0x58, | ||
98 | 0xcb, | ||
99 | 0x65, | ||
100 | 0x48, | ||
101 | 0xf0, | ||
102 | 0x35, | ||
103 | 0x85, | ||
104 | 0xa9, | ||
105 | 0xb2, | ||
106 | 0x8f, | ||
107 | 0x5e, | ||
108 | 0xf3, | ||
109 | 0x80, | ||
110 | 0x94, | ||
111 | 0x97, | ||
112 | 0x7e, | ||
113 | 0x75, | ||
114 | 0x97, | ||
115 | 0x87, | ||
116 | 0x73, | ||
117 | 0x13, | ||
118 | 0xb0, | ||
119 | 0x8a, | ||
120 | 0x69, | ||
121 | 0xd4, | ||
122 | 0x0a, | ||
123 | 0xde, | ||
124 | 0xc1, | ||
125 | 0x79, | ||
126 | 0x59, | ||
127 | 0x36, | ||
128 | 0xdb, | ||
129 | 0x9d, | ||
130 | 0xd6, | ||
131 | 0xb8, | ||
132 | 0x15, | ||
133 | 0x6f, | ||
134 | 0xce, | ||
135 | 0x3c, | ||
136 | 0x72, | ||
137 | 0x32, | ||
138 | 0x45, | ||
139 | 0x88, | ||
140 | 0xdf, | ||
141 | 0x6c, | ||
142 | 0xa5, | ||
143 | 0x6d, | ||
144 | 0xe8, | ||
145 | 0x76, | ||
146 | 0x96, | ||
147 | 0x14, | ||
148 | 0x74, | ||
149 | 0x20, | ||
150 | 0xdc, | ||
151 | 0xf4, | ||
152 | 0xfa, | ||
153 | 0x37, | ||
154 | 0x6a, | ||
155 | 0x27, | ||
156 | 0x32, | ||
157 | 0xe3, | ||
158 | 0x29, | ||
159 | 0xbf, | ||
160 | 0xc4, | ||
161 | 0xc7, | ||
162 | 0x06, | ||
163 | 0x9d, | ||
164 | 0x58, | ||
165 | 0xe7, | ||
166 | 0x87, | ||
167 | 0x7c, | ||
168 | 0x2e, | ||
169 | 0x9f, | ||
170 | 0x6e, | ||
171 | 0x49, | ||
172 | 0x07, | ||
173 | 0x5d, | ||
174 | 0x23, | ||
175 | 0x64, | ||
176 | 0x54, | ||
177 | 0x83, | ||
178 | 0x6e, | ||
179 | 0xcb, | ||
180 | 0xb7, | ||
181 | 0x77, | ||
182 | 0xf7, | ||
183 | 0x2b, | ||
184 | 0x6e, | ||
185 | 0x0f, | ||
186 | 0x2e, | ||
187 | 0x66, | ||
188 | 0x12, | ||
189 | 0x60, | ||
190 | 0x55, | ||
191 | 0x65, | ||
192 | 0xfc, | ||
193 | 0x43, | ||
194 | 0xb3, | ||
195 | 0x58, | ||
196 | 0x73, | ||
197 | 0x5b, | ||
198 | 0xe8, | ||
199 | 0x67, | ||
200 | 0x04, | ||
201 | 0x43, | ||
202 | 0x02, | ||
203 | 0xde, | ||
204 | 0xb3, | ||
205 | 0x89, | ||
206 | 0xa0, | ||
207 | 0x6d, | ||
208 | 0x3a, | ||
209 | 0x27, | ||
210 | 0x79, | ||
211 | 0x64, | ||
212 | 0x5b, | ||
213 | 0x0c, | ||
214 | 0x16, | ||
215 | 0x9e, | ||
216 | 0x66, | ||
217 | 0xb1, | ||
218 | 0x8b, | ||
219 | 0x87, | ||
220 | 0x0c, | ||
221 | 0x5d, | ||
222 | 0xf2, | ||
223 | 0xb6, | ||
224 | 0x3d, | ||
225 | 0x71, | ||
226 | 0xdf, | ||
227 | 0x42, | ||
228 | 0x03, | ||
229 | 0x8a, | ||
230 | 0x06, | ||
231 | 0x8d, | ||
232 | 0xef, | ||
233 | 0x1d, | ||
234 | 0xa8, | ||
235 | 0x96, | ||
236 | 0x5c, | ||
237 | 0xed, | ||
238 | 0x31, | ||
239 | 0x61, | ||
240 | 0x5c, | ||
241 | 0xa1, | ||
242 | 0x34, | ||
243 | 0xf6, | ||
244 | 0x8c, | ||
245 | 0x08, | ||
246 | 0x60, | ||
247 | 0x33, | ||
248 | 0x07, | ||
249 | 0x00, | ||
250 | 0x3e, | ||
251 | 0x79, | ||
252 | 0x95, | ||
253 | 0x1b, | ||
254 | 0x43, | ||
255 | 0x7f, | ||
256 | 0xfe, | ||
257 | 0xb6, | ||
258 | 0xa6, | ||
259 | 0xd4, | ||
260 | 0x9d, | ||
261 | 0x76, | ||
262 | 0x72, | ||
263 | 0xbf, | ||
264 | 0xad, | ||
265 | 0xc0, | ||
266 | 0x15, | ||
267 | 0xe8, | ||
268 | 0x37, | ||
269 | 0x31, | ||
270 | 0xa3, | ||
271 | 0x72, | ||
272 | 0x63, | ||
273 | 0x52, | ||
274 | 0x1d, | ||
275 | 0x1c, | ||
276 | 0x5d, | ||
277 | 0x51, | ||
278 | 0x1b, | ||
279 | 0xe1, | ||
280 | 0xa9, | ||
281 | 0xed, | ||
282 | 0x60, | ||
283 | 0x32, | ||
284 | 0x3e, | ||
285 | 0xa9, | ||
286 | 0x50, | ||
287 | 0x28, | ||
288 | 0x53, | ||
289 | 0x06, | ||
290 | 0x59, | ||
291 | 0xe2, | ||
292 | 0xfc, | ||
293 | 0xe7, | ||
294 | 0x02, | ||
295 | 0x64, | ||
296 | 0x39, | ||
297 | 0x21, | ||
298 | 0x56, | ||
299 | 0x4a, | ||
300 | 0xa5, | ||
301 | 0x40, | ||
302 | 0x80, | ||
303 | 0x81, | ||
304 | 0xd5, | ||
305 | 0x5a, | ||
306 | 0x60, | ||
307 | 0x7b, | ||
308 | 0x68, | ||
309 | 0x84, | ||
310 | 0xf1, | ||
311 | 0xe0, | ||
312 | 0xb1, | ||
313 | 0xb6, | ||
314 | 0x5b, | ||
315 | 0xdf, | ||
316 | 0xa8, | ||
317 | 0x1d, | ||
318 | 0x6d, | ||
319 | 0x65, | ||
320 | 0x20, | ||
321 | 0xc0, | ||
322 | 0xa2, | ||
323 | 0xb9, | ||
324 | 0xd9, | ||
325 | 0xbb, | ||
326 | 0x00, | ||
327 | 0xa6, | ||
328 | 0xdb, | ||
329 | 0x8b, | ||
330 | 0x01, | ||
331 | 0x53, | ||
332 | 0x91, | ||
333 | 0xfe, | ||
334 | 0xc4, | ||
335 | 0x51, | ||
336 | 0x85, | ||
337 | 0xb0, | ||
338 | 0x96, | ||
339 | 0x7f, | ||
340 | 0xfd, | ||
341 | 0x51, | ||
342 | 0xdd, | ||
343 | 0x14, | ||
344 | 0x03, | ||
345 | 0x67, | ||
346 | 0x2e, | ||
347 | 0x75, | ||
348 | 0x1c, | ||
349 | 0x76, | ||
350 | 0xd3, | ||
351 | 0x6e, | ||
352 | 0xdd, | ||
353 | 0x99, | ||
354 | 0x55, | ||
355 | 0x76, | ||
356 | 0xe5, | ||
357 | 0xab, | ||
358 | 0x23, | ||
359 | 0xfc, | ||
360 | 0x4a, | ||
361 | 0xd5, | ||
362 | 0xc6, | ||
363 | 0xe8, | ||
364 | 0x2e, | ||
365 | 0xca, | ||
366 | 0x8a, | ||
367 | 0xb3, | ||
368 | 0xf6, | ||
369 | 0x8c, | ||
370 | 0x6c, | ||
371 | 0xb0, | ||
372 | 0xe9, | ||
373 | 0xf2, | ||
374 | 0xe7, | ||
375 | 0x9e, | ||
376 | 0x69, | ||
377 | 0x41, | ||
378 | 0xed, | ||
379 | 0xf1, | ||
380 | 0x6d, | ||
381 | 0xd2, | ||
382 | 0x86, | ||
383 | 0xd8, | ||
384 | 0x7e, | ||
385 | 0xcb, | ||
386 | 0x5d, | ||
387 | 0x47, | ||
388 | 0x6c, | ||
389 | 0x85, | ||
390 | 0x6a, | ||
391 | 0x23, | ||
392 | 0xed, | ||
393 | 0x20, | ||
394 | 0x40, | ||
395 | 0x93, | ||
396 | 0xb4, | ||
397 | 0x20, | ||
398 | 0xc7, | ||
399 | 0xa5, | ||
400 | 0xc9, | ||
401 | 0xaf, | ||
402 | 0x03, | ||
403 | 0x15, | ||
404 | 0xac, | ||
405 | 0x19, | ||
406 | 0xe5, | ||
407 | 0x2a, | ||
408 | 0x36, | ||
409 | 0xdf, | ||
410 | 0x6d, | ||
411 | 0xc5, | ||
412 | 0x8c, | ||
413 | 0x80, | ||
414 | 0x07, | ||
415 | 0xce, | ||
416 | 0x92, | ||
417 | 0x0c, | ||
418 | 0xd8, | ||
419 | 0x06, | ||
420 | 0x62, | ||
421 | 0x0f, | ||
422 | 0xdd, | ||
423 | 0x48, | ||
424 | 0x46, | ||
425 | 0x1a, | ||
426 | 0x53, | ||
427 | 0xc7, | ||
428 | 0x8a, | ||
429 | 0x8c, | ||
430 | 0x5d, | ||
431 | 0x5d, | ||
432 | 0xb4, | ||
433 | 0xa1, | ||
434 | 0x02, | ||
435 | 0xd3, | ||
436 | 0xa9, | ||
437 | 0xb8, | ||
438 | 0xf3, | ||
439 | 0x94, | ||
440 | 0x8f, | ||
441 | 0x3f, | ||
442 | 0xe5, | ||
443 | 0x54, | ||
444 | 0xd4, | ||
445 | 0x11, | ||
446 | 0x65, | ||
447 | 0xb2, | ||
448 | 0x5e, | ||
449 | 0x09, | ||
450 | 0x0b, | ||
451 | 0x81, | ||
452 | 0xe3, | ||
453 | 0x75, | ||
454 | 0xa7, | ||
455 | 0x89, | ||
456 | 0x81, | ||
457 | 0x39, | ||
458 | 0x6c, | ||
459 | 0x46, | ||
460 | 0xf6, | ||
461 | 0x06, | ||
462 | 0x9f, | ||
463 | 0x27, | ||
464 | 0x3b, | ||
465 | 0xb6, | ||
466 | 0x2d, | ||
467 | 0x5f, | ||
468 | 0x1d, | ||
469 | 0x4b, | ||
470 | 0xd4, | ||
471 | 0x7b, | ||
472 | 0x1d, | ||
473 | 0x61, | ||
474 | 0x74, | ||
475 | 0x89, | ||
476 | 0xe4, | ||
477 | 0xe3, | ||
478 | 0xbd, | ||
479 | 0x98, | ||
480 | 0x1b, | ||
481 | 0xc4, | ||
482 | 0x51, | ||
483 | 0x3b, | ||
484 | 0xa4, | ||
485 | 0xfa, | ||
486 | 0xe0, | ||
487 | 0x92, | ||
488 | 0xf7, | ||
489 | 0xbe, | ||
490 | 0xf2, | ||
491 | 0x4d, | ||
492 | 0xbb, | ||
493 | 0xff, | ||
494 | 0xad, | ||
495 | 0x4f, | ||
496 | 0x6d, | ||
497 | 0x68, | ||
498 | 0xc2, | ||
499 | 0x79, | ||
500 | 0x40, | ||
501 | 0xaa, | ||
502 | 0x9b, | ||
503 | 0x8f, | ||
504 | 0x0c, | ||
505 | 0x32, | ||
506 | 0x4b, | ||
507 | 0x5f, | ||
508 | 0x3e, | ||
509 | 0xab, | ||
510 | 0x59, | ||
511 | 0x98, | ||
512 | 0xb3, | ||
513 | 0xf5, | ||
514 | 0x1d, | ||
515 | 0xac, | ||
516 | 0x5e, | ||
517 | 0xbc, | ||
518 | 0x78, | ||
519 | 0xd3, | ||
520 | 0x01, | ||
521 | 0x6c, | ||
522 | 0x64, | ||
523 | 0x15, | ||
524 | 0x2f, | ||
525 | 0xd8, | ||
526 | 0x71, | ||
527 | 0xa6, | ||
528 | 0x2d, | ||
529 | 0x45, | ||
530 | 0xe1, | ||
531 | 0x22, | ||
532 | 0x42, | ||
533 | 0xe4, | ||
534 | 0x4e, | ||
535 | 0x04, | ||
536 | 0x3c, | ||
537 | 0x7d, | ||
538 | 0xf4, | ||
539 | 0x40, | ||
540 | 0x21, | ||
541 | 0xb4, | ||
542 | 0x67, | ||
543 | 0x05, | ||
544 | 0xa8, | ||
545 | 0xe2, | ||
546 | 0xf3, | ||
547 | 0x72, | ||
548 | 0x87, | ||
549 | 0x4c, | ||
550 | 0x7d, | ||
551 | 0xd9, | ||
552 | 0x1b, | ||
553 | 0x65, | ||
554 | 0x97, | ||
555 | 0xf3, | ||
556 | 0xc2, | ||
557 | 0xe3, | ||
558 | 0xe4, | ||
559 | 0xc8, | ||
560 | 0xd2, | ||
561 | 0xde, | ||
562 | 0xf6, | ||
563 | 0xef, | ||
564 | 0xdc, | ||
565 | 0xbb, | ||
566 | 0x44, | ||
567 | 0x08, | ||
568 | 0x5e, | ||
569 | 0xe2, | ||
570 | 0x45, | ||
571 | 0x27, | ||
572 | 0x01, | ||
573 | 0xb0, | ||
574 | 0xf6, | ||
575 | 0x43, | ||
576 | 0xe7, | ||
577 | 0x3a, | ||
578 | 0xf6, | ||
579 | 0xdc, | ||
580 | 0x9d, | ||
581 | 0xed, | ||
582 | 0xf3, | ||
583 | 0xc5, | ||
584 | 0x0c, | ||
585 | 0xb8, | ||
586 | 0x9c, | ||
587 | 0x98, | ||
588 | 0x3a, | ||
589 | 0xd8, | ||
590 | 0x36, | ||
591 | 0xee, | ||
592 | 0x96, | ||
593 | 0x72, | ||
594 | 0x67, | ||
595 | 0xe7, | ||
596 | 0x81, | ||
597 | 0x91, | ||
598 | 0xd5, | ||
599 | 0x05, | ||
600 | 0x0a, | ||
601 | 0xe0, | ||
602 | 0x82, | ||
603 | 0xd5, | ||
604 | 0x8f, | ||
605 | 0xe8, | ||
606 | 0xf9, | ||
607 | 0xb0, | ||
608 | 0xc9, | ||
609 | 0xcf, | ||
610 | 0x93, | ||
611 | 0xe7, | ||
612 | 0x04, | ||
613 | 0xc5, | ||
614 | 0xbc, | ||
615 | 0x2b, | ||
616 | 0x43, | ||
617 | 0x56, | ||
618 | 0x7e, | ||
619 | 0xe8, | ||
620 | 0x67, | ||
621 | 0x7c, | ||
622 | 0xe5, | ||
623 | 0xfb, | ||
624 | 0x49, | ||
625 | 0xad, | ||
626 | 0x5e, | ||
627 | 0x9f, | ||
628 | 0x25, | ||
629 | 0x13, | ||
630 | 0xde, | ||
631 | 0x6e, | ||
632 | 0x6e, | ||
633 | 0xe9, | ||
634 | 0xf1, | ||
635 | 0xec, | ||
636 | 0x87, | ||
637 | 0x0b, | ||
638 | 0x59, | ||
639 | 0x81, | ||
640 | 0x76, | ||
641 | 0x84, | ||
642 | 0x76, | ||
643 | 0xb3, | ||
644 | 0x24, | ||
645 | 0xaf, | ||
646 | 0x30, | ||
647 | 0xfd, | ||
648 | 0x27, | ||
649 | 0x8b, | ||
650 | 0xab, | ||
651 | 0xd8, | ||
652 | 0x00, | ||
653 | 0x8b, | ||
654 | 0x9b, | ||
655 | 0x0c, | ||
656 | 0xd2, | ||
657 | 0xb2, | ||
658 | 0x4e, | ||
659 | 0x5e, | ||
660 | 0x9d, | ||
661 | 0x1d, | ||
662 | 0x96, | ||
663 | 0x01, | ||
664 | 0x00, | ||
665 | 0x67, | ||
666 | 0xc1, | ||
667 | 0x5f, | ||
668 | 0x02, | ||
669 | 0x20, | ||
670 | 0xfd, | ||
671 | 0x45, | ||
672 | 0x6a, | ||
673 | 0x01, | ||
674 | 0x60, | ||
675 | 0x58, | ||
676 | 0x45, | ||
677 | 0xca, | ||
678 | 0x47, | ||
679 | 0x21, | ||
680 | 0x90, | ||
681 | 0x5a, | ||
682 | 0xc4, | ||
683 | 0x43, | ||
684 | 0x26, | ||
685 | 0x1a, | ||
686 | 0xd7, | ||
687 | 0xa5, | ||
688 | 0x4a, | ||
689 | 0xb2, | ||
690 | 0x5d, | ||
691 | 0x2b, | ||
692 | 0x35, | ||
693 | 0x49, | ||
694 | 0xfb, | ||
695 | 0xa5, | ||
696 | 0x17, | ||
697 | 0x92, | ||
698 | 0x21, | ||
699 | 0x1e, | ||
700 | 0x93, | ||
701 | 0x96, | ||
702 | 0x67, | ||
703 | 0xa2, | ||
704 | 0x7e, | ||
705 | 0x36, | ||
706 | 0x7a, | ||
707 | 0xde, | ||
708 | 0x5f, | ||
709 | 0xbe, | ||
710 | 0x7a, | ||
711 | 0x58, | ||
712 | 0x9d, | ||
713 | 0xf8, | ||
714 | 0x78, | ||
715 | 0xa3, | ||
716 | 0xfa, | ||
717 | 0xc8, | ||
718 | 0xd5, | ||
719 | 0x17, | ||
720 | 0xf0, | ||
721 | 0x21, | ||
722 | 0x97, | ||
723 | 0x8c, | ||
724 | 0x80, | ||
725 | 0xb5, | ||
726 | 0x4b, | ||
727 | 0x3b, | ||
728 | 0xbd, | ||
729 | 0xbb, | ||
730 | 0x41, | ||
731 | 0x21, | ||
732 | 0xa8, | ||
733 | 0x50, | ||
734 | 0x67, | ||
735 | 0xf7, | ||
736 | 0xe7, | ||
737 | 0x19, | ||
738 | 0x80, | ||
739 | 0x10, | ||
740 | 0x8e, | ||
741 | 0xce, | ||
742 | 0x04, | ||
743 | 0x18, | ||
744 | 0x3f, | ||
745 | 0x51, | ||
746 | 0x6b, | ||
747 | 0x77, | ||
748 | 0xd8, | ||
749 | 0x9e, | ||
750 | 0x16, | ||
751 | 0xaf, | ||
752 | 0xec, | ||
753 | 0xef, | ||
754 | 0x48, | ||
755 | 0x16, | ||
756 | 0x4d, | ||
757 | 0x9e, | ||
758 | 0x85, | ||
759 | 0x38, | ||
760 | 0x18, | ||
761 | 0x3e, | ||
762 | 0xd4, | ||
763 | 0x28, | ||
764 | 0x87, | ||
765 | 0x60, | ||
766 | 0x2a, | ||
767 | 0xf6, | ||
768 | 0x7f, | ||
769 | 0x09, | ||
770 | 0x86, | ||
771 | 0x6f, | ||
772 | 0x9c, | ||
773 | 0x3c, | ||
774 | 0x3a, | ||
775 | 0xff, | ||
776 | 0xab, | ||
777 | 0xd0, | ||
778 | 0x61, | ||
779 | 0xa2, | ||
780 | 0x97, | ||
781 | 0x0d, | ||
782 | 0x71, | ||
783 | 0x94, | ||
784 | 0x7e, | ||
785 | 0xfd, | ||
786 | 0xb9, | ||
787 | 0x80, | ||
788 | 0x02, | ||
789 | 0x89, | ||
790 | 0x6a, | ||
791 | 0xb3, | ||
792 | 0x84, | ||
793 | 0x6c, | ||
794 | 0x2a, | ||
795 | 0x77, | ||
796 | 0x62, | ||
797 | 0xbe, | ||
798 | 0x0b, | ||
799 | 0xf4, | ||
800 | 0xaf, | ||
801 | 0xac, | ||
802 | 0x7b, | ||
803 | 0x7c, | ||
804 | 0x8e, | ||
805 | 0xca, | ||
806 | 0x01, | ||
807 | 0xba, | ||
808 | 0x71, | ||
809 | 0x78, | ||
810 | 0x94, | ||
811 | 0xfd, | ||
812 | 0xb5, | ||
813 | 0x39, | ||
814 | 0xa4, | ||
815 | 0x4d, | ||
816 | 0x2f, | ||
817 | 0x78, | ||
818 | 0xcf, | ||
819 | 0xca, | ||
820 | 0x92, | ||
821 | 0x0c, | ||
822 | 0x1a, | ||
823 | 0x99, | ||
824 | 0x48, | ||
825 | 0x4c, | ||
826 | 0x11, | ||
827 | 0x96, | ||
828 | 0xb5, | ||
829 | 0x4e, | ||
830 | 0x41, | ||
831 | 0x28, | ||
832 | 0xe4, | ||
833 | 0xa6, | ||
834 | 0xfe, | ||
835 | 0x4b, | ||
836 | 0x72, | ||
837 | 0x91, | ||
838 | 0xe7, | ||
839 | 0xd4, | ||
840 | 0xdd, | ||
841 | 0x9f, | ||
842 | 0x12, | ||
843 | 0xe6, | ||
844 | 0x29, | ||
845 | 0x38, | ||
846 | 0xce, | ||
847 | 0x45, | ||
848 | 0xae, | ||
849 | 0x02, | ||
850 | 0xb8, | ||
851 | 0x24, | ||
852 | 0xae, | ||
853 | 0xbd, | ||
854 | 0xe9, | ||
855 | 0x66, | ||
856 | 0x08, | ||
857 | 0x62, | ||
858 | 0xa2, | ||
859 | 0x2c, | ||
860 | 0x2b, | ||
861 | 0x00, | ||
862 | 0xe2, | ||
863 | 0x23, | ||
864 | 0xd9, | ||
865 | 0xc4, | ||
866 | 0x48, | ||
867 | 0xe4, | ||
868 | 0xd3, | ||
869 | 0xac, | ||
870 | 0xbb, | ||
871 | 0x34, | ||
872 | 0xc7, | ||
873 | 0xf0, | ||
874 | 0xe3, | ||
875 | 0x4f, | ||
876 | 0xb9, | ||
877 | 0x30, | ||
878 | 0xea, | ||
879 | 0xa2, | ||
880 | 0x12, | ||
881 | 0xf1, | ||
882 | 0x30, | ||
883 | 0x2c, | ||
884 | 0x36, | ||
885 | 0xde, | ||
886 | 0x48, | ||
887 | 0xf2, | ||
888 | 0xb0, | ||
889 | 0x4c, | ||
890 | 0x43, | ||
891 | 0x3f, | ||
892 | 0x2e, | ||
893 | 0x58, | ||
894 | 0xe4, | ||
895 | 0x20, | ||
896 | 0xe3, | ||
897 | 0x58, | ||
898 | 0xcd, | ||
899 | 0x31, | ||
900 | 0x22, | ||
901 | 0xf0, | ||
902 | 0xa2, | ||
903 | 0x2a, | ||
904 | 0xe6, | ||
905 | 0x19, | ||
906 | 0x90, | ||
907 | 0x55, | ||
908 | 0x86, | ||
909 | 0xf6, | ||
910 | 0x55, | ||
911 | 0x79, | ||
912 | 0xd1, | ||
913 | 0xd7, | ||
914 | 0x46, | ||
915 | 0x2f, | ||
916 | 0xc0, | ||
917 | 0xdc, | ||
918 | 0x99, | ||
919 | 0xe8, | ||
920 | 0xf3, | ||
921 | 0x6a, | ||
922 | 0xdf, | ||
923 | 0x7f, | ||
924 | 0xeb, | ||
925 | 0x24, | ||
926 | 0x4a, | ||
927 | 0x1e, | ||
928 | 0x5a, | ||
929 | 0x75, | ||
930 | 0xde, | ||
931 | 0x2f, | ||
932 | 0x5c, | ||
933 | 0x19, | ||
934 | 0x61, | ||
935 | 0x03, | ||
936 | 0x53, | ||
937 | 0x54, | ||
938 | 0x6a, | ||
939 | 0x3b, | ||
940 | 0x18, | ||
941 | 0x70, | ||
942 | 0xb6, | ||
943 | 0x4f, | ||
944 | 0xf1, | ||
945 | 0x9c, | ||
946 | 0x0a, | ||
947 | 0x59, | ||
948 | 0x9d, | ||
949 | 0x19, | ||
950 | 0x92, | ||
951 | 0x65, | ||
952 | 0x8c, | ||
953 | 0x83, | ||
954 | 0x14, | ||
955 | 0x2d, | ||
956 | 0x44, | ||
957 | 0x8a, | ||
958 | 0x75, | ||
959 | 0xa9, | ||
960 | 0xf5, | ||
961 | 0x90, | ||
962 | 0xd2, | ||
963 | 0x66, | ||
964 | 0x4e, | ||
965 | 0xfa, | ||
966 | 0x69, | ||
967 | 0x0f, | ||
968 | 0x5b, | ||
969 | 0x0b, | ||
970 | 0x98, | ||
971 | 0x65, | ||
972 | 0xc8, | ||
973 | 0x11, | ||
974 | 0x42, | ||
975 | 0x59, | ||
976 | 0x7f, | ||
977 | 0xdd, | ||
978 | 0x1b, | ||
979 | 0x75, | ||
980 | 0x17, | ||
981 | 0x31, | ||
982 | 0x4c, | ||
983 | 0x75, | ||
984 | 0x58, | ||
985 | 0xeb, | ||
986 | 0x58, | ||
987 | 0x63, | ||
988 | 0x7d, | ||
989 | 0xf2, | ||
990 | 0xa6, | ||
991 | 0xc2, | ||
992 | 0x6e, | ||
993 | 0xb7, | ||
994 | 0x3f, | ||
995 | 0x3e, | ||
996 | 0x5e, | ||
997 | 0x47, | ||
998 | 0xad, | ||
999 | 0xb7, | ||
1000 | 0x04, | ||
1001 | 0xe8, | ||
1002 | 0x05, | ||
1003 | 0xf8, | ||
1004 | 0xb2, | ||
1005 | 0xcf, | ||
1006 | 0x19, | ||
1007 | 0xf3, | ||
1008 | 0xd2, | ||
1009 | 0x85, | ||
1010 | 0xfe, | ||
1011 | 0x3e, | ||
1012 | 0x3e, | ||
1013 | 0xb1, | ||
1014 | 0x62, | ||
1015 | 0x08, | ||
1016 | 0x2c, | ||
1017 | 0x10, | ||
1018 | 0x07, | ||
1019 | 0x0d, | ||
1020 | 0x73, | ||
1021 | 0x90, | ||
1022 | 0x17, | ||
1023 | 0xfa, | ||
1024 | 0x9b, | ||
1025 | 0x56, | ||
1026 | 0x02, | ||
1027 | 0x75, | ||
1028 | 0xf9, | ||
1029 | 0x51, | ||
1030 | 0xe0, | ||
1031 | 0xe9, | ||
1032 | 0x1a, | ||
1033 | 0x7b, | ||
1034 | 0x9f, | ||
1035 | 0xb3, | ||
1036 | 0xf3, | ||
1037 | 0x98, | ||
1038 | 0xb8, | ||
1039 | 0x1c, | ||
1040 | 0x9c, | ||
1041 | 0xe1, | ||
1042 | 0xd5, | ||
1043 | 0x35, | ||
1044 | 0xae, | ||
1045 | 0xc8, | ||
1046 | 0x60, | ||
1047 | 0x48, | ||
1048 | 0x11, | ||
1049 | 0x09, | ||
1050 | 0x94, | ||
1051 | 0x6b, | ||
1052 | 0xd0, | ||
1053 | 0x8b, | ||
1054 | 0x15, | ||
1055 | 0xbc, | ||
1056 | 0x05, | ||
1057 | 0x68, | ||
1058 | 0xd3, | ||
1059 | 0x54, | ||
1060 | 0x8a, | ||
1061 | 0x51, | ||
1062 | 0x39, | ||
1063 | 0x5c, | ||
1064 | 0x42, | ||
1065 | 0x76, | ||
1066 | 0xce, | ||
1067 | 0xd8, | ||
1068 | 0xad, | ||
1069 | 0x89, | ||
1070 | 0x30, | ||
1071 | 0xc9, | ||
1072 | 0x05, | ||
1073 | 0x1c, | ||
1074 | 0xcc, | ||
1075 | 0x94, | ||
1076 | 0x3f, | ||
1077 | 0x0f, | ||
1078 | 0x90, | ||
1079 | 0x6f, | ||
1080 | 0x72, | ||
1081 | 0x2d, | ||
1082 | 0x85, | ||
1083 | 0x64, | ||
1084 | 0x9a, | ||
1085 | 0xb9, | ||
1086 | 0x23, | ||
1087 | 0xf9, | ||
1088 | 0x0b, | ||
1089 | 0xc3, | ||
1090 | 0x7c, | ||
1091 | 0x39, | ||
1092 | 0x0f, | ||
1093 | 0x97, | ||
1094 | 0x07, | ||
1095 | 0x97, | ||
1096 | 0xda, | ||
1097 | 0x58, | ||
1098 | 0x48, | ||
1099 | 0x33, | ||
1100 | 0x05, | ||
1101 | 0x23, | ||
1102 | 0xb8, | ||
1103 | 0x82, | ||
1104 | 0xe8, | ||
1105 | 0xd3, | ||
1106 | 0x53, | ||
1107 | 0x89, | ||
1108 | 0xaf, | ||
1109 | 0x33, | ||
1110 | 0x80, | ||
1111 | 0x22, | ||
1112 | 0x84, | ||
1113 | 0x0c, | ||
1114 | 0x95, | ||
1115 | 0x5c, | ||
1116 | 0x67, | ||
1117 | 0xb8, | ||
1118 | 0x77, | ||
1119 | 0x0c, | ||
1120 | 0x5c, | ||
1121 | 0xa2, | ||
1122 | 0x5f, | ||
1123 | 0x3d, | ||
1124 | 0x58, | ||
1125 | 0x0f, | ||
1126 | 0x27, | ||
1127 | 0xf3, | ||
1128 | 0x2f, | ||
1129 | 0xae, | ||
1130 | 0x48, | ||
1131 | 0xbd, | ||
1132 | 0x0b, | ||
1133 | 0x6f, | ||
1134 | 0x54, | ||
1135 | 0xfb, | ||
1136 | 0x67, | ||
1137 | 0x4c, | ||
1138 | 0xea, | ||
1139 | 0x32, | ||
1140 | 0x27, | ||
1141 | 0xf1, | ||
1142 | 0xfa, | ||
1143 | 0xe2, | ||
1144 | 0xb0, | ||
1145 | 0xec, | ||
1146 | 0x0b, | ||
1147 | 0x15, | ||
1148 | 0xb4, | ||
1149 | 0x70, | ||
1150 | 0xf6, | ||
1151 | 0x5c, | ||
1152 | 0xdd, | ||
1153 | 0x71, | ||
1154 | 0x60, | ||
1155 | 0xc3, | ||
1156 | 0xc1, | ||
1157 | 0xa8, | ||
1158 | 0x32, | ||
1159 | 0x65, | ||
1160 | 0xac, | ||
1161 | 0x7a, | ||
1162 | 0x77, | ||
1163 | 0x41, | ||
1164 | 0xe5, | ||
1165 | 0xa9, | ||
1166 | 0x6b, | ||
1167 | 0x11, | ||
1168 | 0x81, | ||
1169 | 0xfa, | ||
1170 | 0x34, | ||
1171 | 0x8d, | ||
1172 | 0xfb, | ||
1173 | 0xc1, | ||
1174 | 0x80, | ||
1175 | 0x6e, | ||
1176 | 0xc4, | ||
1177 | 0x60, | ||
1178 | 0x30, | ||
1179 | 0x07, | ||
1180 | 0xd4, | ||
1181 | 0x8b, | ||
1182 | 0x67, | ||
1183 | 0xbd, | ||
1184 | 0xaa, | ||
1185 | 0x8c, | ||
1186 | 0x9c, | ||
1187 | 0x64, | ||
1188 | 0xac, | ||
1189 | 0xdb, | ||
1190 | 0x0b, | ||
1191 | 0x24, | ||
1192 | 0x8b, | ||
1193 | 0x63, | ||
1194 | 0x6f, | ||
1195 | 0xe6, | ||
1196 | 0xbc, | ||
1197 | 0xe7, | ||
1198 | 0x33, | ||
1199 | 0xa4, | ||
1200 | 0x4a, | ||
1201 | 0x4c, | ||
1202 | 0xa7, | ||
1203 | 0x9f, | ||
1204 | 0x43, | ||
1205 | 0x53, | ||
1206 | 0xd2, | ||
1207 | 0xbb, | ||
1208 | 0x8f, | ||
1209 | 0x43, | ||
1210 | 0xc7, | ||
1211 | 0x3d, | ||
1212 | 0x78, | ||
1213 | 0x68, | ||
1214 | 0x3f, | ||
1215 | 0xa5, | ||
1216 | 0x3d, | ||
1217 | 0xca, | ||
1218 | 0x69, | ||
1219 | 0x84, | ||
1220 | 0xa6, | ||
1221 | 0x97, | ||
1222 | 0x2d, | ||
1223 | 0xc0, | ||
1224 | 0x7d, | ||
1225 | 0x31, | ||
1226 | 0x34, | ||
1227 | 0x55, | ||
1228 | 0x1d, | ||
1229 | 0x07, | ||
1230 | 0xb1, | ||
1231 | 0x5f, | ||
1232 | 0x40, | ||
1233 | 0x5c, | ||
1234 | 0x93, | ||
1235 | 0xb0, | ||
1236 | 0xbc, | ||
1237 | 0x7c, | ||
1238 | 0xb0, | ||
1239 | 0xbc, | ||
1240 | 0xe7, | ||
1241 | 0x12, | ||
1242 | 0xee, | ||
1243 | 0x6b, | ||
1244 | 0x2b, | ||
1245 | 0xd3, | ||
1246 | 0x4d, | ||
1247 | 0x67, | ||
1248 | 0x70, | ||
1249 | 0x3a, | ||
1250 | 0x9a, | ||
1251 | 0xf2, | ||
1252 | 0x3c, | ||
1253 | 0x7c, | ||
1254 | 0x81, | ||
1255 | 0xfa, | ||
1256 | 0xd7, | ||
1257 | 0xd9, | ||
1258 | 0x90, | ||
1259 | 0x91, | ||
1260 | 0x81, | ||
1261 | 0xb8, | ||
1262 | 0xb1, | ||
1263 | 0xf3, | ||
1264 | 0x48, | ||
1265 | 0x6a, | ||
1266 | 0x26, | ||
1267 | 0x4f, | ||
1268 | 0x0c, | ||
1269 | 0xce, | ||
1270 | 0xb0, | ||
1271 | 0x9e, | ||
1272 | 0xfd, | ||
1273 | 0x4a, | ||
1274 | 0x3a, | ||
1275 | 0xaf, | ||
1276 | 0xac, | ||
1277 | 0x5b, | ||
1278 | 0x3f, | ||
1279 | 0xbf, | ||
1280 | 0x44, | ||
1281 | 0x5a, | ||
1282 | 0xa3, | ||
1283 | 0x19, | ||
1284 | 0x1e, | ||
1285 | 0x4b, | ||
1286 | 0xe7, | ||
1287 | 0x36, | ||
1288 | 0x6a, | ||
1289 | 0xd7, | ||
1290 | 0x20, | ||
1291 | 0xae, | ||
1292 | 0xd7, | ||
1293 | 0x7d, | ||
1294 | 0x3b, | ||
1295 | 0xe7, | ||
1296 | 0xff, | ||
1297 | 0x3a, | ||
1298 | 0x86, | ||
1299 | 0x2e, | ||
1300 | 0xd0, | ||
1301 | 0x4a, | ||
1302 | 0x3e, | ||
1303 | 0xaf, | ||
1304 | 0x9f, | ||
1305 | 0x8e, | ||
1306 | 0x01, | ||
1307 | 0xbf, | ||
1308 | 0xf8, | ||
1309 | 0x4f, | ||
1310 | 0xc1, | ||
1311 | 0xe8, | ||
1312 | 0x6f, | ||
1313 | 0x74, | ||
1314 | 0xe1, | ||
1315 | 0x45, | ||
1316 | 0xd3, | ||
1317 | 0xf7, | ||
1318 | 0x04, | ||
1319 | 0x6a, | ||
1320 | 0x4b, | ||
1321 | 0x9d, | ||
1322 | 0xec, | ||
1323 | 0x33, | ||
1324 | 0x27, | ||
1325 | 0x76, | ||
1326 | 0xd7, | ||
1327 | 0xc5, | ||
1328 | 0xe1, | ||
1329 | 0xb0, | ||
1330 | 0x3b, | ||
1331 | 0x0e, | ||
1332 | 0x23, | ||
1333 | 0xec, | ||
1334 | 0xf0, | ||
1335 | 0x86, | ||
1336 | 0xd2, | ||
1337 | 0x1a, | ||
1338 | 0xbf, | ||
1339 | 0x3d, | ||
1340 | 0x04, | ||
1341 | 0x62, | ||
1342 | 0xb3, | ||
1343 | 0x6c, | ||
1344 | 0xb2, | ||
1345 | 0xeb, | ||
1346 | 0x17, | ||
1347 | 0x05, | ||
1348 | 0xa6, | ||
1349 | 0x0a, | ||
1350 | 0x8a, | ||
1351 | 0x7e, | ||
1352 | 0x83, | ||
1353 | 0x1c, | ||
1354 | 0xb6, | ||
1355 | 0x37, | ||
1356 | 0x09, | ||
1357 | 0xc6, | ||
1358 | 0x0b, | ||
1359 | 0x70, | ||
1360 | 0x3c, | ||
1361 | 0xb5, | ||
1362 | 0x93, | ||
1363 | 0x81, | ||
1364 | 0xd8, | ||
1365 | 0x93, | ||
1366 | 0xa0, | ||
1367 | 0x5f, | ||
1368 | 0x1e, | ||
1369 | 0x08, | ||
1370 | 0xe2, | ||
1371 | 0xc6, | ||
1372 | 0xe5, | ||
1373 | 0xc9, | ||
1374 | 0x72, | ||
1375 | 0xf1, | ||
1376 | 0xf1, | ||
1377 | 0xc1, | ||
1378 | 0xed, | ||
1379 | 0xd5, | ||
1380 | 0x58, | ||
1381 | 0x93, | ||
1382 | 0x83, | ||
1383 | 0xf8, | ||
1384 | 0x65, | ||
1385 | 0x67, | ||
1386 | 0x2e, | ||
1387 | 0x0d, | ||
1388 | 0xa9, | ||
1389 | 0xf1, | ||
1390 | 0x64, | ||
1391 | 0x12, | ||
1392 | 0xe6, | ||
1393 | 0x4c, | ||
1394 | 0xea, | ||
1395 | 0x15, | ||
1396 | 0x3f, | ||
1397 | 0x8c, | ||
1398 | 0x1a, | ||
1399 | 0xb6, | ||
1400 | 0xbf, | ||
1401 | 0xf6, | ||
1402 | 0xb9, | ||
1403 | 0x52, | ||
1404 | 0x35, | ||
1405 | 0x09, | ||
1406 | 0xb0, | ||
1407 | 0xe6, | ||
1408 | 0xf7, | ||
1409 | 0xcd, | ||
1410 | 0xf1, | ||
1411 | 0xa5, | ||
1412 | 0xaa, | ||
1413 | 0x81, | ||
1414 | 0xd1, | ||
1415 | 0x81, | ||
1416 | 0x6f, | ||
1417 | 0xb4, | ||
1418 | 0xa9, | ||
1419 | 0x66, | ||
1420 | 0x1f, | ||
1421 | 0xfc, | ||
1422 | 0x48, | ||
1423 | 0xc0, | ||
1424 | 0xb6, | ||
1425 | 0xd1, | ||
1426 | 0x8b, | ||
1427 | 0x06, | ||
1428 | 0x2f, | ||
1429 | 0xf6, | ||
1430 | 0xef, | ||
1431 | 0x1f, | ||
1432 | 0x0a, | ||
1433 | 0xe6, | ||
1434 | 0xce, | ||
1435 | 0x3a, | ||
1436 | 0x4a, | ||
1437 | 0x55, | ||
1438 | 0xbf, | ||
1439 | 0x6d, | ||
1440 | 0xf9, | ||
1441 | 0x4d, | ||
1442 | 0xd4, | ||
1443 | 0x08, | ||
1444 | 0x45, | ||
1445 | 0x4b, | ||
1446 | 0xc3, | ||
1447 | 0x66, | ||
1448 | 0x19, | ||
1449 | 0x92, | ||
1450 | 0x10, | ||
1451 | 0xe1, | ||
1452 | 0x17, | ||
1453 | 0x8e, | ||
1454 | 0x28, | ||
1455 | 0x91, | ||
1456 | 0x16, | ||
1457 | 0xbf, | ||
1458 | 0x3c, | ||
1459 | 0xee, | ||
1460 | 0xa3, | ||
1461 | 0xa6, | ||
1462 | 0x99, | ||
1463 | 0x92, | ||
1464 | 0x10, | ||
1465 | 0xe1, | ||
1466 | 0xf6, | ||
1467 | 0xcc, | ||
1468 | 0xac, | ||
1469 | 0xb8, | ||
1470 | 0x65, | ||
1471 | 0x0b, | ||
1472 | 0x43, | ||
1473 | 0x66, | ||
1474 | 0xf8, | ||
1475 | 0xe3, | ||
1476 | 0xe5, | ||
1477 | 0x3f, | ||
1478 | 0x24, | ||
1479 | 0x89, | ||
1480 | 0x47, | ||
1481 | 0x5d, | ||
1482 | 0x78, | ||
1483 | 0x43, | ||
1484 | 0xd0, | ||
1485 | 0x61, | ||
1486 | 0x17, | ||
1487 | 0xbd, | ||
1488 | 0x5b, | ||
1489 | 0x64, | ||
1490 | 0x54, | ||
1491 | 0x08, | ||
1492 | 0x45, | ||
1493 | 0x59, | ||
1494 | 0x93, | ||
1495 | 0xf6, | ||
1496 | 0x95, | ||
1497 | 0x8a, | ||
1498 | 0x41, | ||
1499 | 0x51, | ||
1500 | 0x62, | ||
1501 | 0x4b, | ||
1502 | 0x51, | ||
1503 | 0x02, | ||
1504 | 0x30, | ||
1505 | 0x73, | ||
1506 | 0xc7, | ||
1507 | 0x87, | ||
1508 | 0xc5, | ||
1509 | 0x4b, | ||
1510 | 0xa2, | ||
1511 | 0x97, | ||
1512 | 0x0f, | ||
1513 | 0xe8, | ||
1514 | 0x46, | ||
1515 | 0x5f, | ||
1516 | 0x7e, | ||
1517 | 0x2a, | ||
1518 | 0xe1, | ||
1519 | 0x30, | ||
1520 | 0x20, | ||
1521 | 0xb0, | ||
1522 | 0xfa, | ||
1523 | 0xe7, | ||
1524 | 0xce, | ||
1525 | 0x61, | ||
1526 | 0x42, | ||
1527 | 0x57, | ||
1528 | 0x6e, | ||
1529 | 0x21, | ||
1530 | 0xf3, | ||
1531 | 0x7a, | ||
1532 | 0xec, | ||
1533 | 0xe3, | ||
1534 | 0x25, | ||
1535 | 0xc7, | ||
1536 | 0x25, | ||
1537 | 0xf3, | ||
1538 | 0x67, | ||
1539 | 0xa7, | ||
1540 | 0x57, | ||
1541 | 0x40, | ||
1542 | 0x00, | ||
1543 | 0x02, | ||
1544 | 0xcf, | ||
1545 | 0x1c, | ||
1546 | 0x80, | ||
1547 | 0x77, | ||
1548 | 0x67, | ||
1549 | 0xbd, | ||
1550 | 0x70, | ||
1551 | 0xa1, | ||
1552 | 0x19, | ||
1553 | 0x92, | ||
1554 | 0x31, | ||
1555 | 0x75, | ||
1556 | 0x93, | ||
1557 | 0x27, | ||
1558 | 0x27, | ||
1559 | 0xb6, | ||
1560 | 0x82, | ||
1561 | 0xe4, | ||
1562 | 0xeb, | ||
1563 | 0x1d, | ||
1564 | 0x78, | ||
1565 | 0x48, | ||
1566 | 0xe7, | ||
1567 | 0xa5, | ||
1568 | 0x5e, | ||
1569 | 0x57, | ||
1570 | 0xef, | ||
1571 | 0x64, | ||
1572 | 0x28, | ||
1573 | 0x64, | ||
1574 | 0x1b, | ||
1575 | 0xf6, | ||
1576 | 0x11, | ||
1577 | 0xb2, | ||
1578 | 0x03, | ||
1579 | 0x9d, | ||
1580 | 0xb9, | ||
1581 | 0x18, | ||
1582 | 0x02, | ||
1583 | 0x27, | ||
1584 | 0xf7, | ||
1585 | 0xbe, | ||
1586 | 0x9d, | ||
1587 | 0x55, | ||
1588 | 0xfc, | ||
1589 | 0x00, | ||
1590 | 0xd2, | ||
1591 | 0xc7, | ||
1592 | 0xae, | ||
1593 | 0xad, | ||
1594 | 0x0b, | ||
1595 | 0xc5, | ||
1596 | 0xe9, | ||
1597 | 0x42, | ||
1598 | 0x41, | ||
1599 | 0x48, | ||
1600 | 0xd8, | ||
1601 | 0x32, | ||
1602 | 0xcf, | ||
1603 | 0xf6, | ||
1604 | 0x0f, | ||
1605 | 0xf5, | ||
1606 | 0xbc, | ||
1607 | 0x97, | ||
1608 | 0xc6, | ||
1609 | 0x99, | ||
1610 | 0x47, | ||
1611 | 0x76, | ||
1612 | 0xbd, | ||
1613 | 0x89, | ||
1614 | 0x06, | ||
1615 | 0x0f, | ||
1616 | 0x63, | ||
1617 | 0x0c, | ||
1618 | 0x51, | ||
1619 | 0xd4, | ||
1620 | 0x5e, | ||
1621 | 0xea, | ||
1622 | 0x48, | ||
1623 | 0xa8, | ||
1624 | 0xa2, | ||
1625 | 0x56, | ||
1626 | 0x1c, | ||
1627 | 0x79, | ||
1628 | 0x84, | ||
1629 | 0x86, | ||
1630 | 0x40, | ||
1631 | 0x88, | ||
1632 | 0x41, | ||
1633 | 0x76, | ||
1634 | 0x55, | ||
1635 | 0xfc, | ||
1636 | 0xc2, | ||
1637 | 0xd7, | ||
1638 | 0xfd, | ||
1639 | 0xc9, | ||
1640 | 0xc7, | ||
1641 | 0x80, | ||
1642 | 0x61, | ||
1643 | 0x35, | ||
1644 | 0xa7, | ||
1645 | 0x43, | ||
1646 | 0x20, | ||
1647 | 0xf7, | ||
1648 | 0xeb, | ||
1649 | 0x6c, | ||
1650 | 0x66, | ||
1651 | 0x13, | ||
1652 | 0xb0, | ||
1653 | 0xec, | ||
1654 | 0x02, | ||
1655 | 0x75, | ||
1656 | 0x3e, | ||
1657 | 0x4b, | ||
1658 | 0xaf, | ||
1659 | 0xb9, | ||
1660 | 0x5d, | ||
1661 | 0x40, | ||
1662 | 0xda, | ||
1663 | 0xd6, | ||
1664 | 0x6e, | ||
1665 | 0x2d, | ||
1666 | 0x39, | ||
1667 | 0x54, | ||
1668 | 0xc2, | ||
1669 | 0x95, | ||
1670 | 0x35, | ||
1671 | 0x54, | ||
1672 | 0x25, | ||
1673 | 0x72, | ||
1674 | 0xe1, | ||
1675 | 0x78, | ||
1676 | 0xb8, | ||
1677 | 0xeb, | ||
1678 | 0xc1, | ||
1679 | 0x16, | ||
1680 | 0x58, | ||
1681 | 0x0f, | ||
1682 | 0x9c, | ||
1683 | 0x9b, | ||
1684 | 0xb4, | ||
1685 | 0xea, | ||
1686 | 0x37, | ||
1687 | 0xec, | ||
1688 | 0x3b, | ||
1689 | 0x11, | ||
1690 | 0xba, | ||
1691 | 0xd5, | ||
1692 | 0x8a, | ||
1693 | 0xa9, | ||
1694 | 0xe3, | ||
1695 | 0x98, | ||
1696 | 0x00, | ||
1697 | 0x51, | ||
1698 | 0x1c, | ||
1699 | 0x14, | ||
1700 | 0xe0, | ||
1701 | 0x40, | ||
1702 | 0x96, | ||
1703 | 0xe5, | ||
1704 | 0xe9, | ||
1705 | 0xf2, | ||
1706 | 0x21, | ||
1707 | 0x22, | ||
1708 | 0xb1, | ||
1709 | 0x23, | ||
1710 | 0x60, | ||
1711 | 0x78, | ||
1712 | 0xd3, | ||
1713 | 0x17, | ||
1714 | 0xf8, | ||
1715 | 0x7a, | ||
1716 | 0xa5, | ||
1717 | 0xa8, | ||
1718 | 0xba, | ||
1719 | 0x20, | ||
1720 | 0xd3, | ||
1721 | 0x15, | ||
1722 | 0x1e, | ||
1723 | 0x32, | ||
1724 | 0xe4, | ||
1725 | 0x5e, | ||
1726 | 0x15, | ||
1727 | 0x48, | ||
1728 | 0xae, | ||
1729 | 0xa9, | ||
1730 | 0xe5, | ||
1731 | 0xb8, | ||
1732 | 0x33, | ||
1733 | 0xec, | ||
1734 | 0xe8, | ||
1735 | 0xa2, | ||
1736 | 0x42, | ||
1737 | 0xac, | ||
1738 | 0xbf, | ||
1739 | 0x10, | ||
1740 | 0x84, | ||
1741 | 0x53, | ||
1742 | 0x87, | ||
1743 | 0x19, | ||
1744 | 0xb4, | ||
1745 | 0x5f, | ||
1746 | 0x76, | ||
1747 | 0x4d, | ||
1748 | 0x01, | ||
1749 | 0x9d, | ||
1750 | 0x56, | ||
1751 | 0x74, | ||
1752 | 0xd9, | ||
1753 | 0x5c, | ||
1754 | 0x97, | ||
1755 | 0xe7, | ||
1756 | 0x88, | ||
1757 | 0xea, | ||
1758 | 0x3a, | ||
1759 | 0xbf, | ||
1760 | 0xdc, | ||
1761 | 0x4c, | ||
1762 | 0x33, | ||
1763 | 0x8a, | ||
1764 | 0x16, | ||
1765 | 0xb9, | ||
1766 | 0x5b, | ||
1767 | 0xfa, | ||
1768 | 0xd8, | ||
1769 | 0x42, | ||
1770 | 0xa7, | ||
1771 | 0xbb, | ||
1772 | 0x3c, | ||
1773 | 0x04, | ||
1774 | 0x27, | ||
1775 | 0x78, | ||
1776 | 0x49, | ||
1777 | 0x81, | ||
1778 | 0x2a, | ||
1779 | 0x5a, | ||
1780 | 0x7d, | ||
1781 | 0x7c, | ||
1782 | 0x23, | ||
1783 | 0xa8, | ||
1784 | 0xba, | ||
1785 | 0xf7, | ||
1786 | 0x9a, | ||
1787 | 0x9f, | ||
1788 | 0xd2, | ||
1789 | 0x66, | ||
1790 | 0x3e, | ||
1791 | 0x38, | ||
1792 | 0x3c, | ||
1793 | 0x75, | ||
1794 | 0xf9, | ||
1795 | 0xd1, | ||
1796 | 0x30, | ||
1797 | 0x26, | ||
1798 | 0x30, | ||
1799 | 0x6e, | ||
1800 | 0x5a, | ||
1801 | 0x6e, | ||
1802 | 0xdc, | ||
1803 | 0x6a, | ||
1804 | 0x69, | ||
1805 | 0x32, | ||
1806 | 0x50, | ||
1807 | 0x33, | ||
1808 | 0x47, | ||
1809 | 0x9e, | ||
1810 | 0xa4, | ||
1811 | 0xa8, | ||
1812 | 0x64, | ||
1813 | 0x66, | ||
1814 | 0xf0, | ||
1815 | 0x8a, | ||
1816 | 0xe4, | ||
1817 | 0xfd, | ||
1818 | 0x27, | ||
1819 | 0x6f, | ||
1820 | 0x51, | ||
1821 | 0x25, | ||
1822 | 0x8b, | ||
1823 | 0x43, | ||
1824 | 0x74, | ||
1825 | 0xc9, | ||
1826 | 0x8e, | ||
1827 | 0xbd, | ||
1828 | 0x88, | ||
1829 | 0x31, | ||
1830 | 0xbe, | ||
1831 | 0xec, | ||
1832 | 0x65, | ||
1833 | 0xd2, | ||
1834 | 0xcb, | ||
1835 | 0x8d, | ||
1836 | 0x5a, | ||
1837 | 0x13, | ||
1838 | 0x48, | ||
1839 | 0x16, | ||
1840 | 0x8c, | ||
1841 | 0x61, | ||
1842 | 0x0b, | ||
1843 | 0x11, | ||
1844 | 0xf6, | ||
1845 | 0xc6, | ||
1846 | 0x66, | ||
1847 | 0xae, | ||
1848 | 0xc3, | ||
1849 | 0xcc, | ||
1850 | 0x0c, | ||
1851 | 0xd2, | ||
1852 | 0xe1, | ||
1853 | 0x9f, | ||
1854 | 0x82, | ||
1855 | 0x41, | ||
1856 | 0x3f, | ||
1857 | 0x56, | ||
1858 | 0xf9, | ||
1859 | 0x73, | ||
1860 | 0xef, | ||
1861 | 0xdc, | ||
1862 | 0x30, | ||
1863 | 0x50, | ||
1864 | 0xcf, | ||
1865 | 0xb6, | ||
1866 | 0x7f, | ||
1867 | 0xbc, | ||
1868 | 0xd0, | ||
1869 | 0xb3, | ||
1870 | 0x10, | ||
1871 | 0xab, | ||
1872 | 0x24, | ||
1873 | 0xe4, | ||
1874 | 0xec, | ||
1875 | 0xad, | ||
1876 | 0x18, | ||
1877 | 0x8c, | ||
1878 | 0x39, | ||
1879 | 0x2d, | ||
1880 | 0x30, | ||
1881 | 0x4c, | ||
1882 | 0xc5, | ||
1883 | 0x40, | ||
1884 | 0x0d, | ||
1885 | 0xf6, | ||
1886 | 0xac, | ||
1887 | 0xd6, | ||
1888 | 0x18, | ||
1889 | 0x5d, | ||
1890 | 0x96, | ||
1891 | 0xbf, | ||
1892 | 0x5f, | ||
1893 | 0x71, | ||
1894 | 0x75, | ||
1895 | 0x96, | ||
1896 | 0x22, | ||
1897 | 0x97, | ||
1898 | 0x0f, | ||
1899 | 0x02, | ||
1900 | 0x94, | ||
1901 | 0x6e, | ||
1902 | 0xa6, | ||
1903 | 0xae, | ||
1904 | 0x6d, | ||
1905 | 0x8f, | ||
1906 | 0x1e, | ||
1907 | 0xca, | ||
1908 | 0x12, | ||
1909 | 0x9b, | ||
1910 | 0x2a, | ||
1911 | 0x1c, | ||
1912 | 0xce, | ||
1913 | 0xa9, | ||
1914 | 0xee, | ||
1915 | 0xfd, | ||
1916 | 0x12, | ||
1917 | 0x8e, | ||
1918 | 0xfc, | ||
1919 | 0xed, | ||
1920 | 0x09, | ||
1921 | 0x33, | ||
1922 | 0xba, | ||
1923 | 0xf4, | ||
1924 | 0x1a, | ||
1925 | 0x15, | ||
1926 | 0xf6, | ||
1927 | 0x9d, | ||
1928 | 0x87, | ||
1929 | 0x16, | ||
1930 | 0x43, | ||
1931 | 0x7c, | ||
1932 | 0x78, | ||
1933 | 0x57, | ||
1934 | 0xe1, | ||
1935 | 0x44, | ||
1936 | 0xc9, | ||
1937 | 0xeb, | ||
1938 | 0x1f, | ||
1939 | 0x58, | ||
1940 | 0x4d, | ||
1941 | 0xc1, | ||
1942 | 0x49, | ||
1943 | 0x11, | ||
1944 | 0x5c, | ||
1945 | 0xb2, | ||
1946 | 0x11, | ||
1947 | 0xa8, | ||
1948 | 0x55, | ||
1949 | 0x16, | ||
1950 | 0xf1, | ||
1951 | 0xc6, | ||
1952 | 0x50, | ||
1953 | 0xe9, | ||
1954 | 0x87, | ||
1955 | 0x89, | ||
1956 | 0xf6, | ||
1957 | 0xcf, | ||
1958 | 0xd8, | ||
1959 | 0x9c, | ||
1960 | 0x51, | ||
1961 | 0xa7, | ||
1962 | 0xbc, | ||
1963 | 0x5b, | ||
1964 | 0x31, | ||
1965 | 0x6d, | ||
1966 | 0x4d, | ||
1967 | 0x51, | ||
1968 | 0xd0, | ||
1969 | 0x4c, | ||
1970 | 0xbc, | ||
1971 | 0x0d, | ||
1972 | 0x58, | ||
1973 | 0x2d, | ||
1974 | 0x7b, | ||
1975 | 0x88, | ||
1976 | 0x7a, | ||
1977 | 0xf9, | ||
1978 | 0x8e, | ||
1979 | 0xd6, | ||
1980 | 0x40, | ||
1981 | 0x4d, | ||
1982 | 0xbb, | ||
1983 | 0xbe, | ||
1984 | 0xc4, | ||
1985 | 0xe5, | ||
1986 | 0x07, | ||
1987 | 0xfc, | ||
1988 | 0xd9, | ||
1989 | 0x7b, | ||
1990 | 0x6d, | ||
1991 | 0xa6, | ||
1992 | 0x42, | ||
1993 | 0x57, | ||
1994 | 0x8f, | ||
1995 | 0x02, | ||
1996 | 0x94, | ||
1997 | 0x4f, | ||
1998 | 0xe4, | ||
1999 | 0x2a, | ||
2000 | 0x65, | ||
2001 | 0xe2, | ||
2002 | 0x19, | ||
2003 | 0x5a, | ||
2004 | 0x50, | ||
2005 | 0xe1, | ||
2006 | 0x25, | ||
2007 | 0x65, | ||
2008 | 0x4a, | ||
2009 | 0x60, | ||
2010 | 0xc2, | ||
2011 | 0xcd, | ||
2012 | 0xa8, | ||
2013 | 0xec, | ||
2014 | 0x05, | ||
2015 | 0x2e, | ||
2016 | 0x87, | ||
2017 | 0x7b, | ||
2018 | 0x95, | ||
2019 | 0xb7, | ||
2020 | 0x4f, | ||
2021 | 0xa0, | ||
2022 | 0x0b, | ||
2023 | 0x1b, | ||
2024 | 0x4a, | ||
2025 | 0x7f, | ||
2026 | 0x92, | ||
2027 | 0xc8, | ||
2028 | 0x90, | ||
2029 | 0xee, | ||
2030 | 0x89, | ||
2031 | 0x1e, | ||
2032 | 0x10, | ||
2033 | 0xd2, | ||
2034 | 0x85, | ||
2035 | 0xe4, | ||
2036 | 0x9f, | ||
2037 | 0x63, | ||
2038 | 0xc8, | ||
2039 | 0x12, | ||
2040 | 0xbb, | ||
2041 | 0x4e, | ||
2042 | 0xb8, | ||
2043 | 0xcf, | ||
2044 | 0x0a, | ||
2045 | 0xec, | ||
2046 | 0x18, | ||
2047 | 0x4e, | ||
2048 | 0xe6, | ||
2049 | 0x7c, | ||
2050 | 0xb3, | ||
2051 | 0x33, | ||
2052 | 0x26, | ||
2053 | 0xc7, | ||
2054 | 0x1f, | ||
2055 | 0xd2, | ||
2056 | 0x04, | ||
2057 | 0x23, | ||
2058 | 0xea, | ||
2059 | 0x07, | ||
2060 | 0x0c, | ||
2061 | 0x5f, | ||
2062 | 0x90, | ||
2063 | 0xbd, | ||
2064 | 0xa7, | ||
2065 | 0x6a, | ||
2066 | 0x0f, | ||
2067 | 0x4a, | ||
2068 | 0xd6, | ||
2069 | 0x10, | ||
2070 | 0x01, | ||
2071 | 0x3c, | ||
2072 | 0x12, | ||
2073 | 0x29, | ||
2074 | 0x2e, | ||
2075 | 0x96, | ||
2076 | 0xc0, | ||
2077 | 0x4d, | ||
2078 | 0xbb, | ||
2079 | 0xbe, | ||
2080 | 0xe5, | ||
2081 | 0xa7, | ||
2082 | 0x83, | ||
2083 | 0xd5, | ||
2084 | 0x6a, | ||
2085 | 0x3c, | ||
2086 | 0xe3, | ||
2087 | 0x5b, | ||
2088 | 0xb8, | ||
2089 | 0xf2, | ||
2090 | 0x5c, | ||
2091 | 0x6d, | ||
2092 | 0x1f, | ||
2093 | 0xa6, | ||
2094 | 0xf3, | ||
2095 | 0x12, | ||
2096 | 0x24, | ||
2097 | 0xf6, | ||
2098 | 0xd6, | ||
2099 | 0x3b, | ||
2100 | 0x10, | ||
2101 | 0x14, | ||
2102 | 0x09, | ||
2103 | 0x07, | ||
2104 | 0x82, | ||
2105 | 0xe8, | ||
2106 | 0x30, | ||
2107 | 0x6a, | ||
2108 | 0x99, | ||
2109 | 0xdc, | ||
2110 | 0x95, | ||
2111 | 0x01, | ||
2112 | 0x9c, | ||
2113 | 0xd4, | ||
2114 | 0x68, | ||
2115 | 0x3b, | ||
2116 | 0xca, | ||
2117 | 0x98, | ||
2118 | 0x12, | ||
2119 | 0xab, | ||
2120 | 0x77, | ||
2121 | 0x25, | ||
2122 | 0x15, | ||
2123 | 0x7d, | ||
2124 | 0x10, | ||
2125 | 0x32, | ||
2126 | 0x45, | ||
2127 | 0x98, | ||
2128 | 0xcd, | ||
2129 | 0x7a, | ||
2130 | 0xdf, | ||
2131 | 0x71, | ||
2132 | 0x8a, | ||
2133 | 0x75, | ||
2134 | 0xc1, | ||
2135 | 0x1c, | ||
2136 | 0xd4, | ||
2137 | 0x68, | ||
2138 | 0x25, | ||
2139 | 0xeb, | ||
2140 | 0xbb, | ||
2141 | 0x54, | ||
2142 | 0x27, | ||
2143 | 0x6f, | ||
2144 | 0x2a, | ||
2145 | 0xf7, | ||
2146 | 0xb9, | ||
2147 | 0x98, | ||
2148 | 0x03, | ||
2149 | 0x27, | ||
2150 | 0xde, | ||
2151 | 0x24, | ||
2152 | 0xa8, | ||
2153 | 0xbb, | ||
2154 | 0x98, | ||
2155 | 0xc2, | ||
2156 | 0x84, | ||
2157 | 0xff, | ||
2158 | 0x9b, | ||
2159 | 0x51, | ||
2160 | 0xd8, | ||
2161 | 0x53, | ||
2162 | 0x50, | ||
2163 | 0xda, | ||
2164 | 0xf5, | ||
2165 | 0x88, | ||
2166 | 0xaa, | ||
2167 | 0x87, | ||
2168 | 0x2f, | ||
2169 | 0xae, | ||
2170 | 0xd6, | ||
2171 | 0xea, | ||
2172 | 0x6b, | ||
2173 | 0xde, | ||
2174 | 0xc8, | ||
2175 | 0xd7, | ||
2176 | 0xa7, | ||
2177 | 0x28, | ||
2178 | 0x65, | ||
2179 | 0x81, | ||
2180 | 0xe8, | ||
2181 | 0xb2, | ||
2182 | 0x3b, | ||
2183 | 0x1d, | ||
2184 | 0x4f, | ||
2185 | 0x75, | ||
2186 | 0x8f, | ||
2187 | 0x9f, | ||
2188 | 0x7a, | ||
2189 | 0x74, | ||
2190 | 0x8e, | ||
2191 | 0xc1, | ||
2192 | 0x5f, | ||
2193 | 0x9a, | ||
2194 | 0xa8, | ||
2195 | 0x9d, | ||
2196 | 0xfa, | ||
2197 | 0x03, | ||
2198 | 0xa3, | ||
2199 | 0x71, | ||
2200 | 0x9b, | ||
2201 | 0x37, | ||
2202 | 0x6d, | ||
2203 | 0xd5, | ||
2204 | 0x0b, | ||
2205 | 0xf5, | ||
2206 | 0xe1, | ||
2207 | 0xa1, | ||
2208 | 0x1b, | ||
2209 | 0x01, | ||
2210 | 0x6a, | ||
2211 | 0xc6, | ||
2212 | 0x67, | ||
2213 | 0xaa, | ||
2214 | 0xea, | ||
2215 | 0x2c, | ||
2216 | 0x9d, | ||
2217 | 0xa4, | ||
2218 | 0xd2, | ||
2219 | 0x6e, | ||
2220 | 0xfc, | ||
2221 | 0xde, | ||
2222 | 0x2e, | ||
2223 | 0x7f, | ||
2224 | 0x94, | ||
2225 | 0x69, | ||
2226 | 0xe5, | ||
2227 | 0x4a, | ||
2228 | 0xe0, | ||
2229 | 0x01, | ||
2230 | 0x48, | ||
2231 | 0x3c, | ||
2232 | 0x6b, | ||
2233 | 0xf7, | ||
2234 | 0x1e, | ||
2235 | 0xb6, | ||
2236 | 0x0b, | ||
2237 | 0x5f, | ||
2238 | 0xf9, | ||
2239 | 0x2e, | ||
2240 | 0x07, | ||
2241 | 0xc5, | ||
2242 | 0xe8, | ||
2243 | 0xae, | ||
2244 | 0x37, | ||
2245 | 0x1b, | ||
2246 | 0xbc, | ||
2247 | 0x3c, | ||
2248 | 0xd8, | ||
2249 | 0xd5, | ||
2250 | 0x0b, | ||
2251 | 0x91, | ||
2252 | 0x9e, | ||
2253 | 0x80, | ||
2254 | 0x24, | ||
2255 | 0xf5, | ||
2256 | 0x06, | ||
2257 | 0x0c, | ||
2258 | 0x0e, | ||
2259 | 0x98, | ||
2260 | 0x07, | ||
2261 | 0x96, | ||
2262 | 0x2d, | ||
2263 | 0x19, | ||
2264 | 0xdc, | ||
2265 | 0x58, | ||
2266 | 0x93, | ||
2267 | 0xcc, | ||
2268 | 0xfb, | ||
2269 | 0x4e, | ||
2270 | 0xeb, | ||
2271 | 0xbd, | ||
2272 | 0x0f, | ||
2273 | 0xf5, | ||
2274 | 0xaf, | ||
2275 | 0x01, | ||
2276 | 0xfa, | ||
2277 | 0xf1, | ||
2278 | 0x7c, | ||
2279 | 0x43, | ||
2280 | 0x8c, | ||
2281 | 0xb8, | ||
2282 | 0x56, | ||
2283 | 0x3e, | ||
2284 | 0xbe, | ||
2285 | 0x77, | ||
2286 | 0x4e, | ||
2287 | 0x2b, | ||
2288 | 0xf7, | ||
2289 | 0xbb, | ||
2290 | 0xb7, | ||
2291 | 0x45, | ||
2292 | 0x47, | ||
2293 | 0xcd, | ||
2294 | 0xcc, | ||
2295 | 0xa6, | ||
2296 | 0x4c, | ||
2297 | 0x72, | ||
2298 | 0x7b, | ||
2299 | 0x6a, | ||
2300 | 0x2a, | ||
2301 | 0x70, | ||
2302 | 0x13, | ||
2303 | 0x07, | ||
2304 | 0xfd, | ||
2305 | 0xb8, | ||
2306 | 0x9c, | ||
2307 | 0x98, | ||
2308 | 0x3a, | ||
2309 | 0xd8, | ||
2310 | 0x23, | ||
2311 | 0x67, | ||
2312 | 0x5b, | ||
2313 | 0x34, | ||
2314 | 0xd5, | ||
2315 | 0x14, | ||
2316 | 0x0c, | ||
2317 | 0xab, | ||
2318 | 0x77, | ||
2319 | 0x1f, | ||
2320 | 0xf8, | ||
2321 | 0x3d, | ||
2322 | 0x5a, | ||
2323 | 0x9f, | ||
2324 | 0x92, | ||
2325 | 0xb7, | ||
2326 | 0x2c, | ||
2327 | 0xad, | ||
2328 | 0x31, | ||
2329 | 0xde, | ||
2330 | 0x61, | ||
2331 | 0x07, | ||
2332 | 0xb3, | ||
2333 | 0x6b, | ||
2334 | 0xf7, | ||
2335 | 0x38, | ||
2336 | 0x15, | ||
2337 | 0x95, | ||
2338 | 0x46, | ||
2339 | 0x14, | ||
2340 | 0x48, | ||
2341 | 0x53, | ||
2342 | 0x69, | ||
2343 | 0x52, | ||
2344 | 0x66, | ||
2345 | 0x07, | ||
2346 | 0x6d, | ||
2347 | 0x83, | ||
2348 | 0x71, | ||
2349 | 0x8a, | ||
2350 | 0x67, | ||
2351 | 0x25, | ||
2352 | 0x20, | ||
2353 | 0x0f, | ||
2354 | 0xfe, | ||
2355 | 0xd7, | ||
2356 | 0x02, | ||
2357 | 0xd7, | ||
2358 | 0x6e, | ||
2359 | 0x2c, | ||
2360 | 0xd2, | ||
2361 | 0x1a, | ||
2362 | 0x0a, | ||
2363 | 0x5d, | ||
2364 | 0xfd, | ||
2365 | 0x0f, | ||
2366 | 0x74, | ||
2367 | 0xe3, | ||
2368 | 0xa4, | ||
2369 | 0x36, | ||
2370 | 0x07, | ||
2371 | 0x9a, | ||
2372 | 0xdf, | ||
2373 | 0xd4, | ||
2374 | 0x79, | ||
2375 | 0xbf, | ||
2376 | 0xef, | ||
2377 | 0x59, | ||
2378 | 0xc0, | ||
2379 | 0x44, | ||
2380 | 0x52, | ||
2381 | 0x87, | ||
2382 | 0x9a, | ||
2383 | 0x6e, | ||
2384 | 0x1d, | ||
2385 | 0x0e, | ||
2386 | 0xee, | ||
2387 | 0xde, | ||
2388 | 0x2e, | ||
2389 | 0x1a, | ||
2390 | 0xa9, | ||
2391 | 0x8f, | ||
2392 | 0x3a, | ||
2393 | 0xc9, | ||
2394 | 0xba, | ||
2395 | 0xec, | ||
2396 | 0x99, | ||
2397 | 0x78, | ||
2398 | 0x2d, | ||
2399 | 0x55, | ||
2400 | 0x6b, | ||
2401 | 0x14, | ||
2402 | 0xc2, | ||
2403 | 0x06, | ||
2404 | 0xd5, | ||
2405 | 0xfc, | ||
2406 | 0x93, | ||
2407 | 0x53, | ||
2408 | 0x4d, | ||
2409 | 0x11, | ||
2410 | 0x8c, | ||
2411 | 0xf8, | ||
2412 | 0xfa, | ||
2413 | 0x79, | ||
2414 | 0x7c, | ||
2415 | 0xa6, | ||
2416 | 0x64, | ||
2417 | 0xae, | ||
2418 | 0x61, | ||
2419 | 0xb8, | ||
2420 | 0x7b, | ||
2421 | 0x94, | ||
2422 | 0x56, | ||
2423 | 0xa6, | ||
2424 | 0x39, | ||
2425 | 0x78, | ||
2426 | 0x9a, | ||
2427 | 0xe5, | ||
2428 | 0xc7, | ||
2429 | 0xdf, | ||
2430 | 0x18, | ||
2431 | 0x63, | ||
2432 | 0x23, | ||
2433 | 0x9c, | ||
2434 | 0xfa, | ||
2435 | 0x66, | ||
2436 | 0xbb, | ||
2437 | 0xb7, | ||
2438 | 0x5a, | ||
2439 | 0x27, | ||
2440 | 0x4c, | ||
2441 | 0xd1, | ||
2442 | 0xa1, | ||
2443 | 0x83, | ||
2444 | 0x22, | ||
2445 | 0xb3, | ||
2446 | 0x52, | ||
2447 | 0x49, | ||
2448 | 0x35, | ||
2449 | 0xb0, | ||
2450 | 0x22, | ||
2451 | 0x83, | ||
2452 | 0x59, | ||
2453 | 0x12, | ||
2454 | 0x00, | ||
2455 | 0x16, | ||
2456 | 0x98, | ||
2457 | 0xdd, | ||
2458 | 0xad, | ||
2459 | 0xc2, | ||
2460 | 0x94, | ||
2461 | 0xf9, | ||
2462 | 0xd3, | ||
2463 | 0x7b, | ||
2464 | 0x64, | ||
2465 | 0x7f, | ||
2466 | 0x44, | ||
2467 | 0x3e, | ||
2468 | 0x3c, | ||
2469 | 0x8b, | ||
2470 | 0x9a, | ||
2471 | 0x83, | ||
2472 | 0x9c, | ||
2473 | 0x69, | ||
2474 | 0x6b, | ||
2475 | 0xe4, | ||
2476 | 0xdf, | ||
2477 | 0x9f, | ||
2478 | 0xed, | ||
2479 | 0x54, | ||
2480 | 0x1f, | ||
2481 | 0xe5, | ||
2482 | 0x5d, | ||
2483 | 0x7a, | ||
2484 | 0x05, | ||
2485 | 0x82, | ||
2486 | 0xb3, | ||
2487 | 0xdd, | ||
2488 | 0xef, | ||
2489 | 0xfc, | ||
2490 | 0x53, | ||
2491 | 0x96, | ||
2492 | 0xb0, | ||
2493 | 0x2c, | ||
2494 | 0x5a, | ||
2495 | 0xf8, | ||
2496 | 0xdf, | ||
2497 | 0x9c, | ||
2498 | 0x8b, | ||
2499 | 0x16, | ||
2500 | 0x4e, | ||
2501 | 0xdf, | ||
2502 | 0xda, | ||
2503 | 0x4d, | ||
2504 | 0x09, | ||
2505 | 0x09, | ||
2506 | 0x69, | ||
2507 | 0x50, | ||
2508 | 0x03, | ||
2509 | 0x65, | ||
2510 | 0xd8, | ||
2511 | 0x73, | ||
2512 | 0x70, | ||
2513 | 0xe8, | ||
2514 | 0x86, | ||
2515 | 0xbf, | ||
2516 | 0xbb, | ||
2517 | 0x35, | ||
2518 | 0xce, | ||
2519 | 0xb2, | ||
2520 | 0x46, | ||
2521 | 0xcb, | ||
2522 | 0x02, | ||
2523 | 0x00, | ||
2524 | 0x5b, | ||
2525 | 0xb4, | ||
2526 | 0xe2, | ||
2527 | 0xc6, | ||
2528 | 0x8f, | ||
2529 | 0x2f, | ||
2530 | 0x98, | ||
2531 | 0xaf, | ||
2532 | 0x87, | ||
2533 | 0x4b, | ||
2534 | 0x48, | ||
2535 | 0x45, | ||
2536 | 0xed, | ||
2537 | 0xcc, | ||
2538 | 0x1d, | ||
2539 | 0xe6, | ||
2540 | 0x58, | ||
2541 | 0xd6, | ||
2542 | 0xf2, | ||
2543 | 0x50, | ||
2544 | 0x25, | ||
2545 | 0x9f, | ||
2546 | 0x52, | ||
2547 | 0xc7, | ||
2548 | 0xcb, | ||
2549 | 0x8a, | ||
2550 | 0x17, | ||
2551 | 0x9d, | ||
2552 | 0x5b, | ||
2553 | 0xe5, | ||
2554 | 0xc8, | ||
2555 | 0xd7, | ||
2556 | 0x72, | ||
2557 | 0xb7, | ||
2558 | 0x52, | ||
2559 | 0xb2, | ||
2560 | 0xc4, | ||
2561 | 0x98, | ||
2562 | 0xe3, | ||
2563 | 0x7a, | ||
2564 | 0x17, | ||
2565 | 0x3e, | ||
2566 | 0xc6, | ||
2567 | 0x60, | ||
2568 | 0xa7, | ||
2569 | 0x97, | ||
2570 | 0xb0, | ||
2571 | 0xcf, | ||
2572 | 0x18, | ||
2573 | 0x81, | ||
2574 | 0x53, | ||
2575 | 0x84, | ||
2576 | 0x4c, | ||
2577 | 0xd5, | ||
2578 | 0x17, | ||
2579 | 0x32, | ||
2580 | 0x03, | ||
2581 | 0x13, | ||
2582 | 0x39, | ||
2583 | 0x51, | ||
2584 | 0x09, | ||
2585 | 0x10, | ||
2586 | 0xe3, | ||
2587 | 0x77, | ||
2588 | 0x49, | ||
2589 | 0x4f, | ||
2590 | 0x62, | ||
2591 | 0x01, | ||
2592 | 0xbf, | ||
2593 | 0x8c, | ||
2594 | 0x9a, | ||
2595 | 0xe0, | ||
2596 | 0x41, | ||
2597 | 0x9e, | ||
2598 | 0x89, | ||
2599 | 0x74, | ||
2600 | 0x36, | ||
2601 | 0xf9, | ||
2602 | 0x96, | ||
2603 | 0x86, | ||
2604 | 0x2e, | ||
2605 | 0x96, | ||
2606 | 0x1c, | ||
2607 | 0x4a, | ||
2608 | 0xb7, | ||
2609 | 0x2b, | ||
2610 | 0x4a, | ||
2611 | 0x97, | ||
2612 | 0xbc, | ||
2613 | 0x99, | ||
2614 | 0x40, | ||
2615 | 0xa3, | ||
2616 | 0xe0, | ||
2617 | 0x3d, | ||
2618 | 0xc8, | ||
2619 | 0xad, | ||
2620 | 0x2f, | ||
2621 | 0xdf, | ||
2622 | 0x4f, | ||
2623 | 0x2c, | ||
2624 | 0xc4, | ||
2625 | 0x69, | ||
2626 | 0x82, | ||
2627 | 0x9f, | ||
2628 | 0x9b, | ||
2629 | 0x81, | ||
2630 | 0x0c, | ||
2631 | 0x61, | ||
2632 | 0x5c, | ||
2633 | 0xa5, | ||
2634 | 0x9d, | ||
2635 | 0x8c, | ||
2636 | 0x89, | ||
2637 | 0xc0, | ||
2638 | 0x2c, | ||
2639 | 0xb4, | ||
2640 | 0x4a, | ||
2641 | 0x33, | ||
2642 | 0x4e, | ||
2643 | 0xeb, | ||
2644 | 0xa2, | ||
2645 | 0x56, | ||
2646 | 0x40, | ||
2647 | 0xc0, | ||
2648 | 0xc2, | ||
2649 | 0x46, | ||
2650 | 0xaf, | ||
2651 | 0x6a, | ||
2652 | 0xfc, | ||
2653 | 0x67, | ||
2654 | 0xd1, | ||
2655 | 0x80, | ||
2656 | 0x5e, | ||
2657 | 0xc5, | ||
2658 | 0x6d, | ||
2659 | 0x84, | ||
2660 | 0x43, | ||
2661 | 0x27, | ||
2662 | 0x3f, | ||
2663 | 0x55, | ||
2664 | 0x15, | ||
2665 | 0x96, | ||
2666 | 0x6a, | ||
2667 | 0xa0, | ||
2668 | 0xa5, | ||
2669 | 0xda, | ||
2670 | 0xb7, | ||
2671 | 0xff, | ||
2672 | 0xb7, | ||
2673 | 0x75, | ||
2674 | 0x6e, | ||
2675 | 0x4c, | ||
2676 | 0x49, | ||
2677 | 0x91, | ||
2678 | 0x9d, | ||
2679 | 0x22, | ||
2680 | 0xa3, | ||
2681 | 0x46, | ||
2682 | 0xea, | ||
2683 | 0xed, | ||
2684 | 0x9a, | ||
2685 | 0x00, | ||
2686 | 0xe2, | ||
2687 | 0x32, | ||
2688 | 0xc3, | ||
2689 | 0xd6, | ||
2690 | 0xa9, | ||
2691 | 0x71, | ||
2692 | 0x20, | ||
2693 | 0x55, | ||
2694 | 0xa3, | ||
2695 | 0x19, | ||
2696 | 0xed, | ||
2697 | 0xf8, | ||
2698 | 0x4f, | ||
2699 | 0xa7, | ||
2700 | 0x12, | ||
2701 | 0x9c, | ||
2702 | 0x66, | ||
2703 | 0x87, | ||
2704 | 0xaf, | ||
2705 | 0x4e, | ||
2706 | 0xb7, | ||
2707 | 0xf0, | ||
2708 | 0xdb, | ||
2709 | 0xbf, | ||
2710 | 0xef, | ||
2711 | 0xf0, | ||
2712 | 0xf6, | ||
2713 | 0xaf, | ||
2714 | 0xea, | ||
2715 | 0xda, | ||
2716 | 0x09, | ||
2717 | 0xfe, | ||
2718 | 0xde, | ||
2719 | 0x38, | ||
2720 | 0x5c, | ||
2721 | 0xa5, | ||
2722 | 0xa2, | ||
2723 | 0xdf, | ||
2724 | 0x99, | ||
2725 | 0x45, | ||
2726 | 0xa8, | ||
2727 | 0xe4, | ||
2728 | 0xe7, | ||
2729 | 0x92, | ||
2730 | 0xac, | ||
2731 | 0x67, | ||
2732 | 0xaa, | ||
2733 | 0x4f, | ||
2734 | 0xbf, | ||
2735 | 0x77, | ||
2736 | 0x3e, | ||
2737 | 0xa2, | ||
2738 | 0x40, | ||
2739 | 0x49, | ||
2740 | 0x22, | ||
2741 | 0x4a, | ||
2742 | 0x1e, | ||
2743 | 0x3b, | ||
2744 | 0xaa, | ||
2745 | 0x70, | ||
2746 | 0x7f, | ||
2747 | 0x95, | ||
2748 | 0xaf, | ||
2749 | 0x37, | ||
2750 | 0x4b, | ||
2751 | 0xfc, | ||
2752 | 0x99, | ||
2753 | 0xe2, | ||
2754 | 0xe0, | ||
2755 | 0xba, | ||
2756 | 0xd7, | ||
2757 | 0x34, | ||
2758 | 0xce, | ||
2759 | 0x55, | ||
2760 | 0x88, | ||
2761 | 0x5b, | ||
2762 | 0x84, | ||
2763 | 0x1b, | ||
2764 | 0x57, | ||
2765 | 0xc4, | ||
2766 | 0x80, | ||
2767 | 0x03, | ||
2768 | 0x53, | ||
2769 | 0xc9, | ||
2770 | 0x2f, | ||
2771 | 0x93, | ||
2772 | 0x04, | ||
2773 | 0x4d, | ||
2774 | 0xd5, | ||
2775 | 0x96, | ||
2776 | 0xe5, | ||
2777 | 0x70, | ||
2778 | 0xa6, | ||
2779 | 0x6e, | ||
2780 | 0x63, | ||
2781 | 0x5d, | ||
2782 | 0x9d, | ||
2783 | 0x6c, | ||
2784 | 0xdb, | ||
2785 | 0x02, | ||
2786 | 0x0a, | ||
2787 | 0xa9, | ||
2788 | 0xda, | ||
2789 | 0x8b, | ||
2790 | 0x53, | ||
2791 | 0xdc, | ||
2792 | 0xd9, | ||
2793 | 0x9a, | ||
2794 | 0xc5, | ||
2795 | 0x94, | ||
2796 | 0x2c, | ||
2797 | 0x91, | ||
2798 | 0x92, | ||
2799 | 0x2a, | ||
2800 | 0xde, | ||
2801 | 0xbb, | ||
2802 | 0x8b, | ||
2803 | 0x13, | ||
2804 | 0xb9, | ||
2805 | 0x19, | ||
2806 | 0x96, | ||
2807 | 0x64, | ||
2808 | 0xcc, | ||
2809 | 0xf2, | ||
2810 | 0x64, | ||
2811 | 0x39, | ||
2812 | 0xb7, | ||
2813 | 0x75, | ||
2814 | 0x49, | ||
2815 | 0xe9, | ||
2816 | 0x86, | ||
2817 | 0xc2, | ||
2818 | 0x86, | ||
2819 | 0x62, | ||
2820 | 0xd9, | ||
2821 | 0x24, | ||
2822 | 0xd3, | ||
2823 | 0x81, | ||
2824 | 0x35, | ||
2825 | 0x49, | ||
2826 | 0xfc, | ||
2827 | 0xa0, | ||
2828 | 0xa5, | ||
2829 | 0xa0, | ||
2830 | 0x93, | ||
2831 | 0x05, | ||
2832 | 0x64, | ||
2833 | 0xb4, | ||
2834 | 0x1a, | ||
2835 | 0x57, | ||
2836 | 0xce, | ||
2837 | 0x0c, | ||
2838 | 0x90, | ||
2839 | 0x02, | ||
2840 | 0x27, | ||
2841 | 0xc5, | ||
2842 | 0x7a, | ||
2843 | 0x2b, | ||
2844 | 0x5d, | ||
2845 | 0xae, | ||
2846 | 0x3e, | ||
2847 | 0xd5, | ||
2848 | 0xdd, | ||
2849 | 0x10, | ||
2850 | 0x7c, | ||
2851 | 0x14, | ||
2852 | 0xea, | ||
2853 | 0x3a, | ||
2854 | 0x08, | ||
2855 | 0xac, | ||
2856 | 0x72, | ||
2857 | 0x4e, | ||
2858 | 0x90, | ||
2859 | 0x3d, | ||
2860 | 0x3b, | ||
2861 | 0x7c, | ||
2862 | 0x86, | ||
2863 | 0x2e, | ||
2864 | 0xeb, | ||
2865 | 0xd4, | ||
2866 | 0x06, | ||
2867 | 0x70, | ||
2868 | 0xe6, | ||
2869 | 0xc7, | ||
2870 | 0xfb, | ||
2871 | 0x5f, | ||
2872 | 0xbd, | ||
2873 | 0x18, | ||
2874 | 0xf4, | ||
2875 | 0x11, | ||
2876 | 0xa4, | ||
2877 | 0x1a, | ||
2878 | 0x93, | ||
2879 | 0xc3, | ||
2880 | 0xbe, | ||
2881 | 0xd9, | ||
2882 | 0xfb, | ||
2883 | 0x26, | ||
2884 | 0x48, | ||
2885 | 0x2f, | ||
2886 | 0x37, | ||
2887 | 0x3c, | ||
2888 | 0xd0, | ||
2889 | 0x03, | ||
2890 | 0x47, | ||
2891 | 0x1a, | ||
2892 | 0xf7, | ||
2893 | 0x62, | ||
2894 | 0x19, | ||
2895 | 0x24, | ||
2896 | 0x5c, | ||
2897 | 0xf4, | ||
2898 | 0xa8, | ||
2899 | 0x92, | ||
2900 | 0x20, | ||
2901 | 0x7a, | ||
2902 | 0xf2, | ||
2903 | 0x9e, | ||
2904 | 0x2a, | ||
2905 | 0xc5, | ||
2906 | 0x95, | ||
2907 | 0xa2, | ||
2908 | 0xfb, | ||
2909 | 0xa4, | ||
2910 | 0xea, | ||
2911 | 0x85, | ||
2912 | 0xd8, | ||
2913 | 0x56, | ||
2914 | 0xb7, | ||
2915 | 0x70, | ||
2916 | 0xd1, | ||
2917 | 0x60, | ||
2918 | 0x30, | ||
2919 | 0xa5, | ||
2920 | 0x30, | ||
2921 | 0x82, | ||
2922 | 0x70, | ||
2923 | 0xdc, | ||
2924 | 0x7a, | ||
2925 | 0x65, | ||
2926 | 0x8a, | ||
2927 | 0x36, | ||
2928 | 0x3f, | ||
2929 | 0x5b, | ||
2930 | 0x0c, | ||
2931 | 0xae, | ||
2932 | 0x54, | ||
2933 | 0x7c, | ||
2934 | 0xd3, | ||
2935 | 0x57, | ||
2936 | 0x84, | ||
2937 | 0x7b, | ||
2938 | 0x3a, | ||
2939 | 0x65, | ||
2940 | 0x18, | ||
2941 | 0x81, | ||
2942 | 0xee, | ||
2943 | 0x05, | ||
2944 | 0x9b, | ||
2945 | 0x44, | ||
2946 | 0x4d, | ||
2947 | 0xb8, | ||
2948 | 0xda, | ||
2949 | 0xa2, | ||
2950 | 0xa1, | ||
2951 | 0xc9, | ||
2952 | 0x15, | ||
2953 | 0xd3, | ||
2954 | 0x73, | ||
2955 | 0x03, | ||
2956 | 0x0e, | ||
2957 | 0x43, | ||
2958 | 0xe9, | ||
2959 | 0x8e, | ||
2960 | 0x15, | ||
2961 | 0xf9, | ||
2962 | 0xbe, | ||
2963 | 0xc6, | ||
2964 | 0xc5, | ||
2965 | 0x8a, | ||
2966 | 0xe5, | ||
2967 | 0xc0, | ||
2968 | 0x1e, | ||
2969 | 0xc2, | ||
2970 | 0x37, | ||
2971 | 0x9e, | ||
2972 | 0x2a, | ||
2973 | 0x26, | ||
2974 | 0xa5, | ||
2975 | 0xa0, | ||
2976 | 0xbd, | ||
2977 | 0x24, | ||
2978 | 0x5f, | ||
2979 | 0xb9, | ||
2980 | 0xc1, | ||
2981 | 0xab, | ||
2982 | 0x34, | ||
2983 | 0x48, | ||
2984 | 0xb9, | ||
2985 | 0x5d, | ||
2986 | 0x98, | ||
2987 | 0xb4, | ||
2988 | 0x65, | ||
2989 | 0x18, | ||
2990 | 0xf3, | ||
2991 | 0x63, | ||
2992 | 0x19, | ||
2993 | 0x44, | ||
2994 | 0x1b, | ||
2995 | 0x11, | ||
2996 | 0x16, | ||
2997 | 0xff, | ||
2998 | 0xdc, | ||
2999 | 0xf1, | ||
3000 | 0x79, | ||
3001 | 0x08, | ||
3002 | 0x86, | ||
3003 | 0x0f, | ||
3004 | 0x52, | ||
3005 | 0x98, | ||
3006 | 0x73, | ||
3007 | 0xc4, | ||
3008 | 0x92, | ||
3009 | 0x90, | ||
3010 | 0x2b, | ||
3011 | 0x47, | ||
3012 | 0x09, | ||
3013 | 0xd0, | ||
3014 | 0x43, | ||
3015 | 0x6c, | ||
3016 | 0x2f, | ||
3017 | 0x20, | ||
3018 | 0xeb, | ||
3019 | 0xdc, | ||
3020 | 0xda, | ||
3021 | 0xc5, | ||
3022 | 0x08, | ||
3023 | 0x7b, | ||
3024 | 0x94, | ||
3025 | 0x42, | ||
3026 | 0x30, | ||
3027 | 0x6a, | ||
3028 | 0xc7, | ||
3029 | 0xda, | ||
3030 | 0x8c, | ||
3031 | 0xc3, | ||
3032 | 0x76, | ||
3033 | 0xa7, | ||
3034 | 0xa5, | ||
3035 | 0xcc, | ||
3036 | 0x62, | ||
3037 | 0x13, | ||
3038 | 0x00, | ||
3039 | 0x60, | ||
3040 | 0x31, | ||
3041 | 0x58, | ||
3042 | 0x44, | ||
3043 | 0x9b, | ||
3044 | 0xf5, | ||
3045 | 0x64, | ||
3046 | 0x14, | ||
3047 | 0xf5, | ||
3048 | 0x11, | ||
3049 | 0xc5, | ||
3050 | 0x54, | ||
3051 | 0x52, | ||
3052 | 0x83, | ||
3053 | 0xd4, | ||
3054 | 0x73, | ||
3055 | 0x01, | ||
3056 | 0x16, | ||
3057 | 0x0e, | ||
3058 | 0xb3, | ||
3059 | 0x7a, | ||
3060 | 0x29, | ||
3061 | 0x69, | ||
3062 | 0x35, | ||
3063 | 0x56, | ||
3064 | 0xd4, | ||
3065 | 0xee, | ||
3066 | 0x8a, | ||
3067 | 0x17, | ||
3068 | 0xa2, | ||
3069 | 0x99, | ||
3070 | 0x24, | ||
3071 | 0x9c, | ||
3072 | 0xd7, | ||
3073 | 0x8f, | ||
3074 | 0xdb, | ||
3075 | 0x55, | ||
3076 | 0xb5, | ||
3077 | 0x3e | ||
3078 | }; | ||
diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c new file mode 100644 index 000000000..c0ac644f7 --- /dev/null +++ b/drivers/sensors/pimoroni_trackball.c | |||
@@ -0,0 +1,140 @@ | |||
1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include "pimoroni_trackball.h" | ||
18 | #include "i2c_master.h" | ||
19 | |||
20 | static uint8_t scrolling = 0; | ||
21 | static int16_t x_offset = 0; | ||
22 | static int16_t y_offset = 0; | ||
23 | static int16_t h_offset = 0; | ||
24 | static int16_t v_offset = 0; | ||
25 | static float precisionSpeed = 1; | ||
26 | |||
27 | static uint16_t i2c_timeout_timer; | ||
28 | |||
29 | #ifndef PIMORONI_I2C_TIMEOUT | ||
30 | # define PIMORONI_I2C_TIMEOUT 100 | ||
31 | #endif | ||
32 | #ifndef I2C_WAITCHECK | ||
33 | # define I2C_WAITCHECK 1000 | ||
34 | #endif | ||
35 | #ifndef MOUSE_DEBOUNCE | ||
36 | # define MOUSE_DEBOUNCE 5 | ||
37 | #endif | ||
38 | |||
39 | void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { | ||
40 | uint8_t data[] = {0x00, red, green, blue, white}; | ||
41 | i2c_transmit(TRACKBALL_WRITE, data, sizeof(data), PIMORONI_I2C_TIMEOUT); | ||
42 | } | ||
43 | |||
44 | int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) { | ||
45 | int16_t offset = (int16_t)positive - (int16_t)negative; | ||
46 | int16_t magnitude = (int16_t)(scale * offset * offset * precisionSpeed); | ||
47 | return offset < 0 ? -magnitude : magnitude; | ||
48 | } | ||
49 | |||
50 | void update_member(int8_t* member, int16_t* offset) { | ||
51 | if (*offset > 127) { | ||
52 | *member = 127; | ||
53 | *offset -= 127; | ||
54 | } else if (*offset < -127) { | ||
55 | *member = -127; | ||
56 | *offset += 127; | ||
57 | } else { | ||
58 | *member = *offset; | ||
59 | *offset = 0; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | __attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* mouse) { | ||
64 | if (pressed) { | ||
65 | mouse->buttons |= MOUSE_BTN1; | ||
66 | } else { | ||
67 | mouse->buttons &= ~MOUSE_BTN1; | ||
68 | } | ||
69 | } | ||
70 | |||
71 | float trackball_get_precision(void) { return precisionSpeed; } | ||
72 | void trackball_set_precision(float precision) { precisionSpeed = precision; } | ||
73 | bool trackball_is_scrolling(void) { return scrolling; } | ||
74 | void trackball_set_scrolling(bool scroll) { scrolling = scroll; } | ||
75 | |||
76 | __attribute__((weak)) void pointing_device_init(void) { i2c_init(); trackball_set_rgbw(0x00, 0x00, 0x00, 0x00); } | ||
77 | |||
78 | void pointing_device_task(void) { | ||
79 | static bool debounce; | ||
80 | static uint16_t debounce_timer; | ||
81 | uint8_t state[5] = {}; | ||
82 | if (timer_elapsed(i2c_timeout_timer) > I2C_WAITCHECK) { | ||
83 | if (i2c_readReg(TRACKBALL_READ, 0x04, state, 5, PIMORONI_I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { | ||
84 | if (!state[4] && !debounce) { | ||
85 | if (scrolling) { | ||
86 | #ifdef PIMORONI_TRACKBALL_INVERT_X | ||
87 | h_offset += mouse_offset(state[2], state[3], 1); | ||
88 | #else | ||
89 | h_offset -= mouse_offset(state[2], state[3], 1); | ||
90 | #endif | ||
91 | #ifdef PIMORONI_TRACKBALL_INVERT_Y | ||
92 | v_offset += mouse_offset(state[1], state[0], 1); | ||
93 | #else | ||
94 | v_offset -= mouse_offset(state[1], state[0], 1); | ||
95 | #endif | ||
96 | } else { | ||
97 | #ifdef PIMORONI_TRACKBALL_INVERT_X | ||
98 | x_offset -= mouse_offset(state[2], state[3], 5); | ||
99 | #else | ||
100 | x_offset += mouse_offset(state[2], state[3], 5); | ||
101 | #endif | ||
102 | #ifdef PIMORONI_TRACKBALL_INVERT_Y | ||
103 | y_offset -= mouse_offset(state[1], state[0], 5); | ||
104 | #else | ||
105 | y_offset += mouse_offset(state[1], state[0], 5); | ||
106 | #endif | ||
107 | } | ||
108 | } else { | ||
109 | if (state[4]) { | ||
110 | debounce = true; | ||
111 | debounce_timer = timer_read(); | ||
112 | } | ||
113 | } | ||
114 | } else { | ||
115 | i2c_timeout_timer = timer_read(); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | if (timer_elapsed(debounce_timer) > MOUSE_DEBOUNCE) debounce = false; | ||
120 | |||
121 | report_mouse_t mouse = pointing_device_get_report(); | ||
122 | |||
123 | #ifdef PIMORONI_TRACKBALL_CLICK | ||
124 | trackball_check_click(state[4] & (1 << 7), &mouse); | ||
125 | #endif | ||
126 | |||
127 | #ifndef PIMORONI_TRACKBALL_ROTATE | ||
128 | update_member(&mouse.x, &x_offset); | ||
129 | update_member(&mouse.y, &y_offset); | ||
130 | update_member(&mouse.h, &h_offset); | ||
131 | update_member(&mouse.v, &v_offset); | ||
132 | #else | ||
133 | update_member(&mouse.x, &y_offset); | ||
134 | update_member(&mouse.y, &x_offset); | ||
135 | update_member(&mouse.h, &v_offset); | ||
136 | update_member(&mouse.v, &h_offset); | ||
137 | #endif | ||
138 | pointing_device_set_report(mouse); | ||
139 | pointing_device_send(); | ||
140 | } | ||
diff --git a/drivers/sensors/pimoroni_trackball.h b/drivers/sensors/pimoroni_trackball.h new file mode 100644 index 000000000..a30fb0bb8 --- /dev/null +++ b/drivers/sensors/pimoroni_trackball.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include "quantum.h" | ||
20 | #include "pointing_device.h" | ||
21 | |||
22 | #ifndef TRACKBALL_ADDRESS | ||
23 | # define TRACKBALL_ADDRESS 0x0A | ||
24 | #endif | ||
25 | #define TRACKBALL_WRITE ((TRACKBALL_ADDRESS << 1) | I2C_WRITE) | ||
26 | #define TRACKBALL_READ ((TRACKBALL_ADDRESS << 1) | I2C_READ) | ||
27 | |||
28 | void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); | ||
29 | void trackball_check_click(bool pressed, report_mouse_t *mouse); | ||
30 | void trackball_register_button(bool pressed, enum mouse_buttons button); | ||
31 | |||
32 | float trackball_get_precision(void); | ||
33 | void trackball_set_precision(float precision); | ||
34 | bool trackball_is_scrolling(void); | ||
35 | void trackball_set_scrolling(bool scroll); | ||
diff --git a/drivers/sensors/pmw3360.c b/drivers/sensors/pmw3360.c new file mode 100644 index 000000000..91ee87b95 --- /dev/null +++ b/drivers/sensors/pmw3360.c | |||
@@ -0,0 +1,237 @@ | |||
1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
2 | * Copyright 2019 Sunjun Kim | ||
3 | * Copyright 2020 Ploopy Corporation | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include "wait.h" | ||
20 | #include "debug.h" | ||
21 | #include "print.h" | ||
22 | #include "pmw3360.h" | ||
23 | #include "pmw3360_firmware.h" | ||
24 | |||
25 | bool _inBurst = false; | ||
26 | |||
27 | #ifndef PMW_CPI | ||
28 | # define PMW_CPI 1600 | ||
29 | #endif | ||
30 | #ifndef PMW_CLOCK_SPEED | ||
31 | # define PMW_CLOCK_SPEED 70000000 | ||
32 | #endif | ||
33 | #ifndef SPI_MODE | ||
34 | # define SPI_MODE 3 | ||
35 | #endif | ||
36 | #ifndef SPI_DIVISOR | ||
37 | # define SPI_DIVISOR (F_CPU / PMW_CLOCK_SPEED) | ||
38 | #endif | ||
39 | #ifndef ROTATIONAL_TRANSFORM_ANGLE | ||
40 | # define ROTATIONAL_TRANSFORM_ANGLE 0x00 | ||
41 | #endif | ||
42 | #ifndef PMW_CS_PIN | ||
43 | # define PMW_CS_PIN SPI_SS_PIN | ||
44 | #endif | ||
45 | |||
46 | void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } | ||
47 | |||
48 | bool spi_start_adv(void) { | ||
49 | bool status = spi_start(PMW_CS_PIN, false, SPI_MODE, SPI_DIVISOR); | ||
50 | wait_us(1); | ||
51 | return status; | ||
52 | } | ||
53 | |||
54 | void spi_stop_adv(void) { | ||
55 | wait_us(1); | ||
56 | spi_stop(); | ||
57 | } | ||
58 | |||
59 | spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data) { | ||
60 | if (reg_addr != REG_Motion_Burst) { | ||
61 | _inBurst = false; | ||
62 | } | ||
63 | |||
64 | spi_start_adv(); | ||
65 | // send address of the register, with MSBit = 1 to indicate it's a write | ||
66 | spi_status_t status = spi_write(reg_addr | 0x80); | ||
67 | status = spi_write(data); | ||
68 | |||
69 | // tSCLK-NCS for write operation | ||
70 | wait_us(20); | ||
71 | |||
72 | // tSWW/tSWR (=120us) minus tSCLK-NCS. Could be shortened, but is looks like a safe lower bound | ||
73 | wait_us(100); | ||
74 | spi_stop(); | ||
75 | return status; | ||
76 | } | ||
77 | |||
78 | uint8_t spi_read_adv(uint8_t reg_addr) { | ||
79 | spi_start_adv(); | ||
80 | // send adress of the register, with MSBit = 0 to indicate it's a read | ||
81 | spi_write(reg_addr & 0x7f); | ||
82 | |||
83 | uint8_t data = spi_read(); | ||
84 | |||
85 | // tSCLK-NCS for read operation is 120ns | ||
86 | wait_us(1); | ||
87 | |||
88 | // tSRW/tSRR (=20us) minus tSCLK-NCS | ||
89 | wait_us(19); | ||
90 | |||
91 | spi_stop(); | ||
92 | return data; | ||
93 | } | ||
94 | |||
95 | void pmw_set_cpi(uint16_t cpi) { | ||
96 | uint8_t cpival = constrain((cpi / 100) - 1, 0, 0x77); // limits to 0--119 | ||
97 | |||
98 | spi_start_adv(); | ||
99 | spi_write_adv(REG_Config1, cpival); | ||
100 | spi_stop(); | ||
101 | } | ||
102 | |||
103 | uint16_t pmw_get_cpi(void) { | ||
104 | uint8_t cpival = spi_read_adv(REG_Config1); | ||
105 | return (uint16_t)(cpival & 0xFF) * 100; | ||
106 | } | ||
107 | |||
108 | bool pmw_spi_init(void) { | ||
109 | setPinOutput(PMW_CS_PIN); | ||
110 | |||
111 | spi_init(); | ||
112 | _inBurst = false; | ||
113 | |||
114 | spi_stop(); | ||
115 | spi_start_adv(); | ||
116 | spi_stop(); | ||
117 | |||
118 | spi_write_adv(REG_Shutdown, 0xb6); // Shutdown first | ||
119 | wait_ms(300); | ||
120 | |||
121 | spi_start_adv(); | ||
122 | wait_us(40); | ||
123 | spi_stop_adv(); | ||
124 | wait_us(40); | ||
125 | |||
126 | spi_write_adv(REG_Power_Up_Reset, 0x5a); | ||
127 | wait_ms(50); | ||
128 | |||
129 | spi_read_adv(REG_Motion); | ||
130 | spi_read_adv(REG_Delta_X_L); | ||
131 | spi_read_adv(REG_Delta_X_H); | ||
132 | spi_read_adv(REG_Delta_Y_L); | ||
133 | spi_read_adv(REG_Delta_Y_H); | ||
134 | |||
135 | pmw_upload_firmware(); | ||
136 | |||
137 | spi_stop_adv(); | ||
138 | |||
139 | wait_ms(10); | ||
140 | pmw_set_cpi(PMW_CPI); | ||
141 | |||
142 | wait_ms(1); | ||
143 | |||
144 | spi_write_adv(REG_Config2, 0x00); | ||
145 | |||
146 | spi_write_adv(REG_Angle_Tune, constrain(ROTATIONAL_TRANSFORM_ANGLE, -30, 30)); | ||
147 | |||
148 | bool init_success = pmw_check_signature(); | ||
149 | |||
150 | writePinLow(PMW_CS_PIN); | ||
151 | |||
152 | return init_success; | ||
153 | } | ||
154 | |||
155 | void pmw_upload_firmware(void) { | ||
156 | spi_write_adv(REG_SROM_Enable, 0x1d); | ||
157 | |||
158 | wait_ms(10); | ||
159 | |||
160 | spi_write_adv(REG_SROM_Enable, 0x18); | ||
161 | |||
162 | spi_start_adv(); | ||
163 | spi_write(REG_SROM_Load_Burst | 0x80); | ||
164 | wait_us(15); | ||
165 | |||
166 | unsigned char c; | ||
167 | for (int i = 0; i < firmware_length; i++) { | ||
168 | c = (unsigned char)pgm_read_byte(firmware_data + i); | ||
169 | spi_write(c); | ||
170 | wait_us(15); | ||
171 | } | ||
172 | wait_us(200); | ||
173 | |||
174 | spi_read_adv(REG_SROM_ID); | ||
175 | |||
176 | spi_write_adv(REG_Config2, 0x00); | ||
177 | |||
178 | spi_stop(); | ||
179 | wait_ms(10); | ||
180 | } | ||
181 | |||
182 | bool pmw_check_signature(void) { | ||
183 | uint8_t pid = spi_read_adv(REG_Product_ID); | ||
184 | uint8_t iv_pid = spi_read_adv(REG_Inverse_Product_ID); | ||
185 | uint8_t SROM_ver = spi_read_adv(REG_SROM_ID); | ||
186 | return (pid == 0x42 && iv_pid == 0xBD && SROM_ver == 0x04); // signature for SROM 0x04 | ||
187 | } | ||
188 | |||
189 | report_pmw_t pmw_read_burst(void) { | ||
190 | if (!_inBurst) { | ||
191 | dprintf("burst on"); | ||
192 | spi_write_adv(REG_Motion_Burst, 0x00); | ||
193 | _inBurst = true; | ||
194 | } | ||
195 | |||
196 | spi_start_adv(); | ||
197 | spi_write(REG_Motion_Burst); | ||
198 | wait_us(35); // waits for tSRAD | ||
199 | |||
200 | report_pmw_t data; | ||
201 | data.motion = 0; | ||
202 | data.dx = 0; | ||
203 | data.mdx = 0; | ||
204 | data.dy = 0; | ||
205 | data.mdx = 0; | ||
206 | |||
207 | data.motion = spi_read(); | ||
208 | spi_write(0x00); // skip Observation | ||
209 | data.dx = spi_read(); | ||
210 | data.mdx = spi_read(); | ||
211 | data.dy = spi_read(); | ||
212 | data.mdy = spi_read(); | ||
213 | |||
214 | spi_stop(); | ||
215 | |||
216 | print_byte(data.motion); | ||
217 | print_byte(data.dx); | ||
218 | print_byte(data.mdx); | ||
219 | print_byte(data.dy); | ||
220 | print_byte(data.mdy); | ||
221 | dprintf("\n"); | ||
222 | |||
223 | data.isMotion = (data.motion & 0x80) != 0; | ||
224 | data.isOnSurface = (data.motion & 0x08) == 0; | ||
225 | data.dx |= (data.mdx << 8); | ||
226 | data.dx = data.dx * -1; | ||
227 | data.dy |= (data.mdy << 8); | ||
228 | data.dy = data.dy * -1; | ||
229 | |||
230 | spi_stop(); | ||
231 | |||
232 | if (data.motion & 0b111) { // panic recovery, sometimes burst mode works weird. | ||
233 | _inBurst = false; | ||
234 | } | ||
235 | |||
236 | return data; | ||
237 | } | ||
diff --git a/drivers/sensors/pmw3360.h b/drivers/sensors/pmw3360.h new file mode 100644 index 000000000..d5b174179 --- /dev/null +++ b/drivers/sensors/pmw3360.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
2 | * Copyright 2019 Sunjun Kim | ||
3 | * Copyright 2020 Ploopy Corporation | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #pragma once | ||
20 | |||
21 | #include "spi_master.h" | ||
22 | |||
23 | // Registers | ||
24 | #define REG_Product_ID 0x00 | ||
25 | #define REG_Revision_ID 0x01 | ||
26 | #define REG_Motion 0x02 | ||
27 | #define REG_Delta_X_L 0x03 | ||
28 | #define REG_Delta_X_H 0x04 | ||
29 | #define REG_Delta_Y_L 0x05 | ||
30 | #define REG_Delta_Y_H 0x06 | ||
31 | #define REG_SQUAL 0x07 | ||
32 | #define REG_Raw_Data_Sum 0x08 | ||
33 | #define REG_Maximum_Raw_data 0x09 | ||
34 | #define REG_Minimum_Raw_data 0x0A | ||
35 | #define REG_Shutter_Lower 0x0B | ||
36 | #define REG_Shutter_Upper 0x0C | ||
37 | #define REG_Control 0x0D | ||
38 | #define REG_Config1 0x0F | ||
39 | #define REG_Config2 0x10 | ||
40 | #define REG_Angle_Tune 0x11 | ||
41 | #define REG_Frame_Capture 0x12 | ||
42 | #define REG_SROM_Enable 0x13 | ||
43 | #define REG_Run_Downshift 0x14 | ||
44 | #define REG_Rest1_Rate_Lower 0x15 | ||
45 | #define REG_Rest1_Rate_Upper 0x16 | ||
46 | #define REG_Rest1_Downshift 0x17 | ||
47 | #define REG_Rest2_Rate_Lower 0x18 | ||
48 | #define REG_Rest2_Rate_Upper 0x19 | ||
49 | #define REG_Rest2_Downshift 0x1A | ||
50 | #define REG_Rest3_Rate_Lower 0x1B | ||
51 | #define REG_Rest3_Rate_Upper 0x1C | ||
52 | #define REG_Observation 0x24 | ||
53 | #define REG_Data_Out_Lower 0x25 | ||
54 | #define REG_Data_Out_Upper 0x26 | ||
55 | #define REG_Raw_Data_Dump 0x29 | ||
56 | #define REG_SROM_ID 0x2A | ||
57 | #define REG_Min_SQ_Run 0x2B | ||
58 | #define REG_Raw_Data_Threshold 0x2C | ||
59 | #define REG_Config5 0x2F | ||
60 | #define REG_Power_Up_Reset 0x3A | ||
61 | #define REG_Shutdown 0x3B | ||
62 | #define REG_Inverse_Product_ID 0x3F | ||
63 | #define REG_LiftCutoff_Tune3 0x41 | ||
64 | #define REG_Angle_Snap 0x42 | ||
65 | #define REG_LiftCutoff_Tune1 0x4A | ||
66 | #define REG_Motion_Burst 0x50 | ||
67 | #define REG_LiftCutoff_Tune_Timeout 0x58 | ||
68 | #define REG_LiftCutoff_Tune_Min_Length 0x5A | ||
69 | #define REG_SROM_Load_Burst 0x62 | ||
70 | #define REG_Lift_Config 0x63 | ||
71 | #define REG_Raw_Data_Burst 0x64 | ||
72 | #define REG_LiftCutoff_Tune2 0x65 | ||
73 | |||
74 | #ifdef CONSOLE_ENABLE | ||
75 | void print_byte(uint8_t byte); | ||
76 | #endif | ||
77 | |||
78 | typedef struct { | ||
79 | int8_t motion; | ||
80 | bool isMotion; // True if a motion is detected. | ||
81 | bool isOnSurface; // True when a chip is on a surface | ||
82 | int16_t dx; // displacement on x directions. Unit: Count. (CPI * Count = Inch value) | ||
83 | int8_t mdx; | ||
84 | int16_t dy; // displacement on y directions. | ||
85 | int8_t mdy; | ||
86 | } report_pmw_t; | ||
87 | |||
88 | |||
89 | |||
90 | bool spi_start_adv(void); | ||
91 | void spi_stop_adv(void); | ||
92 | spi_status_t spi_write_adv(uint8_t reg_addr, uint8_t data); | ||
93 | uint8_t spi_read_adv(uint8_t reg_addr); | ||
94 | bool pmw_spi_init(void); | ||
95 | void pmw_set_cpi(uint16_t cpi); | ||
96 | uint16_t pmw_get_cpi(void); | ||
97 | void pmw_upload_firmware(void); | ||
98 | bool pmw_check_signature(void); | ||
99 | report_pmw_t pmw_read_burst(void); | ||
100 | |||
101 | |||
102 | #define degToRad(angleInDegrees) ((angleInDegrees)*M_PI / 180.0) | ||
103 | #define radToDeg(angleInRadians) ((angleInRadians)*180.0 / M_PI) | ||
104 | #define constrain(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt))) | ||
diff --git a/drivers/sensors/pmw3360_firmware.h b/drivers/sensors/pmw3360_firmware.h new file mode 100644 index 000000000..cca5a6a4d --- /dev/null +++ b/drivers/sensors/pmw3360_firmware.h | |||
@@ -0,0 +1,300 @@ | |||
1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
2 | * Copyright 2019 Sunjun Kim | ||
3 | * Copyright 2020 Ploopy Corporation | ||
4 | * | ||
5 | * This program is free software: you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation, either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #pragma once | ||
20 | |||
21 | // clang-format off | ||
22 | // Firmware Blob foor PMW3360 | ||
23 | const uint16_t firmware_length = 4094; | ||
24 | // clang-format off | ||
25 | const uint8_t firmware_data[] PROGMEM = { // SROM 0x04 | ||
26 | 0x01, 0x04, 0x8e, 0x96, 0x6e, 0x77, 0x3e, 0xfe, 0x7e, 0x5f, 0x1d, 0xb8, 0xf2, 0x66, 0x4e, | ||
27 | 0xff, 0x5d, 0x19, 0xb0, 0xc2, 0x04, 0x69, 0x54, 0x2a, 0xd6, 0x2e, 0xbf, 0xdd, 0x19, 0xb0, | ||
28 | 0xc3, 0xe5, 0x29, 0xb1, 0xe0, 0x23, 0xa5, 0xa9, 0xb1, 0xc1, 0x00, 0x82, 0x67, 0x4c, 0x1a, | ||
29 | 0x97, 0x8d, 0x79, 0x51, 0x20, 0xc7, 0x06, 0x8e, 0x7c, 0x7c, 0x7a, 0x76, 0x4f, 0xfd, 0x59, | ||
30 | 0x30, 0xe2, 0x46, 0x0e, 0x9e, 0xbe, 0xdf, 0x1d, 0x99, 0x91, 0xa0, 0xa5, 0xa1, 0xa9, 0xd0, | ||
31 | 0x22, 0xc6, 0xef, 0x5c, 0x1b, 0x95, 0x89, 0x90, 0xa2, 0xa7, 0xcc, 0xfb, 0x55, 0x28, 0xb3, | ||
32 | 0xe4, 0x4a, 0xf7, 0x6c, 0x3b, 0xf4, 0x6a, 0x56, 0x2e, 0xde, 0x1f, 0x9d, 0xb8, 0xd3, 0x05, | ||
33 | 0x88, 0x92, 0xa6, 0xce, 0x1e, 0xbe, 0xdf, 0x1d, 0x99, 0xb0, 0xe2, 0x46, 0xef, 0x5c, 0x07, | ||
34 | 0x11, 0x5d, 0x98, 0x0b, 0x9d, 0x94, 0x97, 0xee, 0x4e, 0x45, 0x33, 0x6b, 0x44, 0xc7, 0x29, | ||
35 | 0x56, 0x27, 0x30, 0xc6, 0xa7, 0xd5, 0xf2, 0x56, 0xdf, 0xb4, 0x38, 0x62, 0xcb, 0xa0, 0xb6, | ||
36 | 0xe3, 0x0f, 0x84, 0x06, 0x24, 0x05, 0x65, 0x6f, 0x76, 0x89, 0xb5, 0x77, 0x41, 0x27, 0x82, | ||
37 | 0x66, 0x65, 0x82, 0xcc, 0xd5, 0xe6, 0x20, 0xd5, 0x27, 0x17, 0xc5, 0xf8, 0x03, 0x23, 0x7c, | ||
38 | 0x5f, 0x64, 0xa5, 0x1d, 0xc1, 0xd6, 0x36, 0xcb, 0x4c, 0xd4, 0xdb, 0x66, 0xd7, 0x8b, 0xb1, | ||
39 | 0x99, 0x7e, 0x6f, 0x4c, 0x36, 0x40, 0x06, 0xd6, 0xeb, 0xd7, 0xa2, 0xe4, 0xf4, 0x95, 0x51, | ||
40 | 0x5a, 0x54, 0x96, 0xd5, 0x53, 0x44, 0xd7, 0x8c, 0xe0, 0xb9, 0x40, 0x68, 0xd2, 0x18, 0xe9, | ||
41 | 0xdd, 0x9a, 0x23, 0x92, 0x48, 0xee, 0x7f, 0x43, 0xaf, 0xea, 0x77, 0x38, 0x84, 0x8c, 0x0a, | ||
42 | 0x72, 0xaf, 0x69, 0xf8, 0xdd, 0xf1, 0x24, 0x83, 0xa3, 0xf8, 0x4a, 0xbf, 0xf5, 0x94, 0x13, | ||
43 | 0xdb, 0xbb, 0xd8, 0xb4, 0xb3, 0xa0, 0xfb, 0x45, 0x50, 0x60, 0x30, 0x59, 0x12, 0x31, 0x71, | ||
44 | 0xa2, 0xd3, 0x13, 0xe7, 0xfa, 0xe7, 0xce, 0x0f, 0x63, 0x15, 0x0b, 0x6b, 0x94, 0xbb, 0x37, | ||
45 | 0x83, 0x26, 0x05, 0x9d, 0xfb, 0x46, 0x92, 0xfc, 0x0a, 0x15, 0xd1, 0x0d, 0x73, 0x92, 0xd6, | ||
46 | 0x8c, 0x1b, 0x8c, 0xb8, 0x55, 0x8a, 0xce, 0xbd, 0xfe, 0x8e, 0xfc, 0xed, 0x09, 0x12, 0x83, | ||
47 | 0x91, 0x82, 0x51, 0x31, 0x23, 0xfb, 0xb4, 0x0c, 0x76, 0xad, 0x7c, 0xd9, 0xb4, 0x4b, 0xb2, | ||
48 | 0x67, 0x14, 0x09, 0x9c, 0x7f, 0x0c, 0x18, 0xba, 0x3b, 0xd6, 0x8e, 0x14, 0x2a, 0xe4, 0x1b, | ||
49 | 0x52, 0x9f, 0x2b, 0x7d, 0xe1, 0xfb, 0x6a, 0x33, 0x02, 0xfa, 0xac, 0x5a, 0xf2, 0x3e, 0x88, | ||
50 | 0x7e, 0xae, 0xd1, 0xf3, 0x78, 0xe8, 0x05, 0xd1, 0xe3, 0xdc, 0x21, 0xf6, 0xe1, 0x9a, 0xbd, | ||
51 | 0x17, 0x0e, 0xd9, 0x46, 0x9b, 0x88, 0x03, 0xea, 0xf6, 0x66, 0xbe, 0x0e, 0x1b, 0x50, 0x49, | ||
52 | 0x96, 0x40, 0x97, 0xf1, 0xf1, 0xe4, 0x80, 0xa6, 0x6e, 0xe8, 0x77, 0x34, 0xbf, 0x29, 0x40, | ||
53 | 0x44, 0xc2, 0xff, 0x4e, 0x98, 0xd3, 0x9c, 0xa3, 0x32, 0x2b, 0x76, 0x51, 0x04, 0x09, 0xe7, | ||
54 | 0xa9, 0xd1, 0xa6, 0x32, 0xb1, 0x23, 0x53, 0xe2, 0x47, 0xab, 0xd6, 0xf5, 0x69, 0x5c, 0x3e, | ||
55 | 0x5f, 0xfa, 0xae, 0x45, 0x20, 0xe5, 0xd2, 0x44, 0xff, 0x39, 0x32, 0x6d, 0xfd, 0x27, 0x57, | ||
56 | 0x5c, 0xfd, 0xf0, 0xde, 0xc1, 0xb5, 0x99, 0xe5, 0xf5, 0x1c, 0x77, 0x01, 0x75, 0xc5, 0x6d, | ||
57 | 0x58, 0x92, 0xf2, 0xb2, 0x47, 0x00, 0x01, 0x26, 0x96, 0x7a, 0x30, 0xff, 0xb7, 0xf0, 0xef, | ||
58 | 0x77, 0xc1, 0x8a, 0x5d, 0xdc, 0xc0, 0xd1, 0x29, 0x30, 0x1e, 0x77, 0x38, 0x7a, 0x94, 0xf1, | ||
59 | 0xb8, 0x7a, 0x7e, 0xef, 0xa4, 0xd1, 0xac, 0x31, 0x4a, 0xf2, 0x5d, 0x64, 0x3d, 0xb2, 0xe2, | ||
60 | 0xf0, 0x08, 0x99, 0xfc, 0x70, 0xee, 0x24, 0xa7, 0x7e, 0xee, 0x1e, 0x20, 0x69, 0x7d, 0x44, | ||
61 | 0xbf, 0x87, 0x42, 0xdf, 0x88, 0x3b, 0x0c, 0xda, 0x42, 0xc9, 0x04, 0xf9, 0x45, 0x50, 0xfc, | ||
62 | 0x83, 0x8f, 0x11, 0x6a, 0x72, 0xbc, 0x99, 0x95, 0xf0, 0xac, 0x3d, 0xa7, 0x3b, 0xcd, 0x1c, | ||
63 | 0xe2, 0x88, 0x79, 0x37, 0x11, 0x5f, 0x39, 0x89, 0x95, 0x0a, 0x16, 0x84, 0x7a, 0xf6, 0x8a, | ||
64 | 0xa4, 0x28, 0xe4, 0xed, 0x83, 0x80, 0x3b, 0xb1, 0x23, 0xa5, 0x03, 0x10, 0xf4, 0x66, 0xea, | ||
65 | 0xbb, 0x0c, 0x0f, 0xc5, 0xec, 0x6c, 0x69, 0xc5, 0xd3, 0x24, 0xab, 0xd4, 0x2a, 0xb7, 0x99, | ||
66 | 0x88, 0x76, 0x08, 0xa0, 0xa8, 0x95, 0x7c, 0xd8, 0x38, 0x6d, 0xcd, 0x59, 0x02, 0x51, 0x4b, | ||
67 | 0xf1, 0xb5, 0x2b, 0x50, 0xe3, 0xb6, 0xbd, 0xd0, 0x72, 0xcf, 0x9e, 0xfd, 0x6e, 0xbb, 0x44, | ||
68 | 0xc8, 0x24, 0x8a, 0x77, 0x18, 0x8a, 0x13, 0x06, 0xef, 0x97, 0x7d, 0xfa, 0x81, 0xf0, 0x31, | ||
69 | 0xe6, 0xfa, 0x77, 0xed, 0x31, 0x06, 0x31, 0x5b, 0x54, 0x8a, 0x9f, 0x30, 0x68, 0xdb, 0xe2, | ||
70 | 0x40, 0xf8, 0x4e, 0x73, 0xfa, 0xab, 0x74, 0x8b, 0x10, 0x58, 0x13, 0xdc, 0xd2, 0xe6, 0x78, | ||
71 | 0xd1, 0x32, 0x2e, 0x8a, 0x9f, 0x2c, 0x58, 0x06, 0x48, 0x27, 0xc5, 0xa9, 0x5e, 0x81, 0x47, | ||
72 | 0x89, 0x46, 0x21, 0x91, 0x03, 0x70, 0xa4, 0x3e, 0x88, 0x9c, 0xda, 0x33, 0x0a, 0xce, 0xbc, | ||
73 | 0x8b, 0x8e, 0xcf, 0x9f, 0xd3, 0x71, 0x80, 0x43, 0xcf, 0x6b, 0xa9, 0x51, 0x83, 0x76, 0x30, | ||
74 | 0x82, 0xc5, 0x6a, 0x85, 0x39, 0x11, 0x50, 0x1a, 0x82, 0xdc, 0x1e, 0x1c, 0xd5, 0x7d, 0xa9, | ||
75 | 0x71, 0x99, 0x33, 0x47, 0x19, 0x97, 0xb3, 0x5a, 0xb1, 0xdf, 0xed, 0xa4, 0xf2, 0xe6, 0x26, | ||
76 | 0x84, 0xa2, 0x28, 0x9a, 0x9e, 0xdf, 0xa6, 0x6a, 0xf4, 0xd6, 0xfc, 0x2e, 0x5b, 0x9d, 0x1a, | ||
77 | 0x2a, 0x27, 0x68, 0xfb, 0xc1, 0x83, 0x21, 0x4b, 0x90, 0xe0, 0x36, 0xdd, 0x5b, 0x31, 0x42, | ||
78 | 0x55, 0xa0, 0x13, 0xf7, 0xd0, 0x89, 0x53, 0x71, 0x99, 0x57, 0x09, 0x29, 0xc5, 0xf3, 0x21, | ||
79 | 0xf8, 0x37, 0x2f, 0x40, 0xf3, 0xd4, 0xaf, 0x16, 0x08, 0x36, 0x02, 0xfc, 0x77, 0xc5, 0x8b, | ||
80 | 0x04, 0x90, 0x56, 0xb9, 0xc9, 0x67, 0x9a, 0x99, 0xe8, 0x00, 0xd3, 0x86, 0xff, 0x97, 0x2d, | ||
81 | 0x08, 0xe9, 0xb7, 0xb3, 0x91, 0xbc, 0xdf, 0x45, 0xc6, 0xed, 0x0f, 0x8c, 0x4c, 0x1e, 0xe6, | ||
82 | 0x5b, 0x6e, 0x38, 0x30, 0xe4, 0xaa, 0xe3, 0x95, 0xde, 0xb9, 0xe4, 0x9a, 0xf5, 0xb2, 0x55, | ||
83 | 0x9a, 0x87, 0x9b, 0xf6, 0x6a, 0xb2, 0xf2, 0x77, 0x9a, 0x31, 0xf4, 0x7a, 0x31, 0xd1, 0x1d, | ||
84 | 0x04, 0xc0, 0x7c, 0x32, 0xa2, 0x9e, 0x9a, 0xf5, 0x62, 0xf8, 0x27, 0x8d, 0xbf, 0x51, 0xff, | ||
85 | 0xd3, 0xdf, 0x64, 0x37, 0x3f, 0x2a, 0x6f, 0x76, 0x3a, 0x7d, 0x77, 0x06, 0x9e, 0x77, 0x7f, | ||
86 | 0x5e, 0xeb, 0x32, 0x51, 0xf9, 0x16, 0x66, 0x9a, 0x09, 0xf3, 0xb0, 0x08, 0xa4, 0x70, 0x96, | ||
87 | 0x46, 0x30, 0xff, 0xda, 0x4f, 0xe9, 0x1b, 0xed, 0x8d, 0xf8, 0x74, 0x1f, 0x31, 0x92, 0xb3, | ||
88 | 0x73, 0x17, 0x36, 0xdb, 0x91, 0x30, 0xd6, 0x88, 0x55, 0x6b, 0x34, 0x77, 0x87, 0x7a, 0xe7, | ||
89 | 0xee, 0x06, 0xc6, 0x1c, 0x8c, 0x19, 0x0c, 0x48, 0x46, 0x23, 0x5e, 0x9c, 0x07, 0x5c, 0xbf, | ||
90 | 0xb4, 0x7e, 0xd6, 0x4f, 0x74, 0x9c, 0xe2, 0xc5, 0x50, 0x8b, 0xc5, 0x8b, 0x15, 0x90, 0x60, | ||
91 | 0x62, 0x57, 0x29, 0xd0, 0x13, 0x43, 0xa1, 0x80, 0x88, 0x91, 0x00, 0x44, 0xc7, 0x4d, 0x19, | ||
92 | 0x86, 0xcc, 0x2f, 0x2a, 0x75, 0x5a, 0xfc, 0xeb, 0x97, 0x2a, 0x70, 0xe3, 0x78, 0xd8, 0x91, | ||
93 | 0xb0, 0x4f, 0x99, 0x07, 0xa3, 0x95, 0xea, 0x24, 0x21, 0xd5, 0xde, 0x51, 0x20, 0x93, 0x27, | ||
94 | 0x0a, 0x30, 0x73, 0xa8, 0xff, 0x8a, 0x97, 0xe9, 0xa7, 0x6a, 0x8e, 0x0d, 0xe8, 0xf0, 0xdf, | ||
95 | 0xec, 0xea, 0xb4, 0x6c, 0x1d, 0x39, 0x2a, 0x62, 0x2d, 0x3d, 0x5a, 0x8b, 0x65, 0xf8, 0x90, | ||
96 | 0x05, 0x2e, 0x7e, 0x91, 0x2c, 0x78, 0xef, 0x8e, 0x7a, 0xc1, 0x2f, 0xac, 0x78, 0xee, 0xaf, | ||
97 | 0x28, 0x45, 0x06, 0x4c, 0x26, 0xaf, 0x3b, 0xa2, 0xdb, 0xa3, 0x93, 0x06, 0xb5, 0x3c, 0xa5, | ||
98 | 0xd8, 0xee, 0x8f, 0xaf, 0x25, 0xcc, 0x3f, 0x85, 0x68, 0x48, 0xa9, 0x62, 0xcc, 0x97, 0x8f, | ||
99 | 0x7f, 0x2a, 0xea, 0xe0, 0x15, 0x0a, 0xad, 0x62, 0x07, 0xbd, 0x45, 0xf8, 0x41, 0xd8, 0x36, | ||
100 | 0xcb, 0x4c, 0xdb, 0x6e, 0xe6, 0x3a, 0xe7, 0xda, 0x15, 0xe9, 0x29, 0x1e, 0x12, 0x10, 0xa0, | ||
101 | 0x14, 0x2c, 0x0e, 0x3d, 0xf4, 0xbf, 0x39, 0x41, 0x92, 0x75, 0x0b, 0x25, 0x7b, 0xa3, 0xce, | ||
102 | 0x39, 0x9c, 0x15, 0x64, 0xc8, 0xfa, 0x3d, 0xef, 0x73, 0x27, 0xfe, 0x26, 0x2e, 0xce, 0xda, | ||
103 | 0x6e, 0xfd, 0x71, 0x8e, 0xdd, 0xfe, 0x76, 0xee, 0xdc, 0x12, 0x5c, 0x02, 0xc5, 0x3a, 0x4e, | ||
104 | 0x4e, 0x4f, 0xbf, 0xca, 0x40, 0x15, 0xc7, 0x6e, 0x8d, 0x41, 0xf1, 0x10, 0xe0, 0x4f, 0x7e, | ||
105 | 0x97, 0x7f, 0x1c, 0xae, 0x47, 0x8e, 0x6b, 0xb1, 0x25, 0x31, 0xb0, 0x73, 0xc7, 0x1b, 0x97, | ||
106 | 0x79, 0xf9, 0x80, 0xd3, 0x66, 0x22, 0x30, 0x07, 0x74, 0x1e, 0xe4, 0xd0, 0x80, 0x21, 0xd6, | ||
107 | 0xee, 0x6b, 0x6c, 0x4f, 0xbf, 0xf5, 0xb7, 0xd9, 0x09, 0x87, 0x2f, 0xa9, 0x14, 0xbe, 0x27, | ||
108 | 0xd9, 0x72, 0x50, 0x01, 0xd4, 0x13, 0x73, 0xa6, 0xa7, 0x51, 0x02, 0x75, 0x25, 0xe1, 0xb3, | ||
109 | 0x45, 0x34, 0x7d, 0xa8, 0x8e, 0xeb, 0xf3, 0x16, 0x49, 0xcb, 0x4f, 0x8c, 0xa1, 0xb9, 0x36, | ||
110 | 0x85, 0x39, 0x75, 0x5d, 0x08, 0x00, 0xae, 0xeb, 0xf6, 0xea, 0xd7, 0x13, 0x3a, 0x21, 0x5a, | ||
111 | 0x5f, 0x30, 0x84, 0x52, 0x26, 0x95, 0xc9, 0x14, 0xf2, 0x57, 0x55, 0x6b, 0xb1, 0x10, 0xc2, | ||
112 | 0xe1, 0xbd, 0x3b, 0x51, 0xc0, 0xb7, 0x55, 0x4c, 0x71, 0x12, 0x26, 0xc7, 0x0d, 0xf9, 0x51, | ||
113 | 0xa4, 0x38, 0x02, 0x05, 0x7f, 0xb8, 0xf1, 0x72, 0x4b, 0xbf, 0x71, 0x89, 0x14, 0xf3, 0x77, | ||
114 | 0x38, 0xd9, 0x71, 0x24, 0xf3, 0x00, 0x11, 0xa1, 0xd8, 0xd4, 0x69, 0x27, 0x08, 0x37, 0x35, | ||
115 | 0xc9, 0x11, 0x9d, 0x90, 0x1c, 0x0e, 0xe7, 0x1c, 0xff, 0x2d, 0x1e, 0xe8, 0x92, 0xe1, 0x18, | ||
116 | 0x10, 0x95, 0x7c, 0xe0, 0x80, 0xf4, 0x96, 0x43, 0x21, 0xf9, 0x75, 0x21, 0x64, 0x38, 0xdd, | ||
117 | 0x9f, 0x1e, 0x95, 0x16, 0xda, 0x56, 0x1d, 0x4f, 0x9a, 0x53, 0xb2, 0xe2, 0xe4, 0x18, 0xcb, | ||
118 | 0x6b, 0x1a, 0x65, 0xeb, 0x56, 0xc6, 0x3b, 0xe5, 0xfe, 0xd8, 0x26, 0x3f, 0x3a, 0x84, 0x59, | ||
119 | 0x72, 0x66, 0xa2, 0xf3, 0x75, 0xff, 0xfb, 0x60, 0xb3, 0x22, 0xad, 0x3f, 0x2d, 0x6b, 0xf9, | ||
120 | 0xeb, 0xea, 0x05, 0x7c, 0xd8, 0x8f, 0x6d, 0x2c, 0x98, 0x9e, 0x2b, 0x93, 0xf1, 0x5e, 0x46, | ||
121 | 0xf0, 0x87, 0x49, 0x29, 0x73, 0x68, 0xd7, 0x7f, 0xf9, 0xf0, 0xe5, 0x7d, 0xdb, 0x1d, 0x75, | ||
122 | 0x19, 0xf3, 0xc4, 0x58, 0x9b, 0x17, 0x88, 0xa8, 0x92, 0xe0, 0xbe, 0xbd, 0x8b, 0x1d, 0x8d, | ||
123 | 0x9f, 0x56, 0x76, 0xad, 0xaf, 0x29, 0xe2, 0xd9, 0xd5, 0x52, 0xf6, 0xb5, 0x56, 0x35, 0x57, | ||
124 | 0x3a, 0xc8, 0xe1, 0x56, 0x43, 0x19, 0x94, 0xd3, 0x04, 0x9b, 0x6d, 0x35, 0xd8, 0x0b, 0x5f, | ||
125 | 0x4d, 0x19, 0x8e, 0xec, 0xfa, 0x64, 0x91, 0x0a, 0x72, 0x20, 0x2b, 0xbc, 0x1a, 0x4a, 0xfe, | ||
126 | 0x8b, 0xfd, 0xbb, 0xed, 0x1b, 0x23, 0xea, 0xad, 0x72, 0x82, 0xa1, 0x29, 0x99, 0x71, 0xbd, | ||
127 | 0xf0, 0x95, 0xc1, 0x03, 0xdd, 0x7b, 0xc2, 0xb2, 0x3c, 0x28, 0x54, 0xd3, 0x68, 0xa4, 0x72, | ||
128 | 0xc8, 0x66, 0x96, 0xe0, 0xd1, 0xd8, 0x7f, 0xf8, 0xd1, 0x26, 0x2b, 0xf7, 0xad, 0xba, 0x55, | ||
129 | 0xca, 0x15, 0xb9, 0x32, 0xc3, 0xe5, 0x88, 0x97, 0x8e, 0x5c, 0xfb, 0x92, 0x25, 0x8b, 0xbf, | ||
130 | 0xa2, 0x45, 0x55, 0x7a, 0xa7, 0x6f, 0x8b, 0x57, 0x5b, 0xcf, 0x0e, 0xcb, 0x1d, 0xfb, 0x20, | ||
131 | 0x82, 0x77, 0xa8, 0x8c, 0xcc, 0x16, 0xce, 0x1d, 0xfa, 0xde, 0xcc, 0x0b, 0x62, 0xfe, 0xcc, | ||
132 | 0xe1, 0xb7, 0xf0, 0xc3, 0x81, 0x64, 0x73, 0x40, 0xa0, 0xc2, 0x4d, 0x89, 0x11, 0x75, 0x33, | ||
133 | 0x55, 0x33, 0x8d, 0xe8, 0x4a, 0xfd, 0xea, 0x6e, 0x30, 0x0b, 0xd7, 0x31, 0x2c, 0xde, 0x47, | ||
134 | 0xe3, 0xbf, 0xf8, 0x55, 0x42, 0xe2, 0x7f, 0x59, 0xe5, 0x17, 0xef, 0x99, 0x34, 0x69, 0x91, | ||
135 | 0xb1, 0x23, 0x8e, 0x20, 0x87, 0x2d, 0xa8, 0xfe, 0xd5, 0x8a, 0xf3, 0x84, 0x3a, 0xf0, 0x37, | ||
136 | 0xe4, 0x09, 0x00, 0x54, 0xee, 0x67, 0x49, 0x93, 0xe4, 0x81, 0x70, 0xe3, 0x90, 0x4d, 0xef, | ||
137 | 0xfe, 0x41, 0xb7, 0x99, 0x7b, 0xc1, 0x83, 0xba, 0x62, 0x12, 0x6f, 0x7d, 0xde, 0x6b, 0xaf, | ||
138 | 0xda, 0x16, 0xf9, 0x55, 0x51, 0xee, 0xa6, 0x0c, 0x2b, 0x02, 0xa3, 0xfd, 0x8d, 0xfb, 0x30, | ||
139 | 0x17, 0xe4, 0x6f, 0xdf, 0x36, 0x71, 0xc4, 0xca, 0x87, 0x25, 0x48, 0xb0, 0x47, 0xec, 0xea, | ||
140 | 0xb4, 0xbf, 0xa5, 0x4d, 0x9b, 0x9f, 0x02, 0x93, 0xc4, 0xe3, 0xe4, 0xe8, 0x42, 0x2d, 0x68, | ||
141 | 0x81, 0x15, 0x0a, 0xeb, 0x84, 0x5b, 0xd6, 0xa8, 0x74, 0xfb, 0x7d, 0x1d, 0xcb, 0x2c, 0xda, | ||
142 | 0x46, 0x2a, 0x76, 0x62, 0xce, 0xbc, 0x5c, 0x9e, 0x8b, 0xe7, 0xcf, 0xbe, 0x78, 0xf5, 0x7c, | ||
143 | 0xeb, 0xb3, 0x3a, 0x9c, 0xaa, 0x6f, 0xcc, 0x72, 0xd1, 0x59, 0xf2, 0x11, 0x23, 0xd6, 0x3f, | ||
144 | 0x48, 0xd1, 0xb7, 0xce, 0xb0, 0xbf, 0xcb, 0xea, 0x80, 0xde, 0x57, 0xd4, 0x5e, 0x97, 0x2f, | ||
145 | 0x75, 0xd1, 0x50, 0x8e, 0x80, 0x2c, 0x66, 0x79, 0xbf, 0x72, 0x4b, 0xbd, 0x8a, 0x81, 0x6c, | ||
146 | 0xd3, 0xe1, 0x01, 0xdc, 0xd2, 0x15, 0x26, 0xc5, 0x36, 0xda, 0x2c, 0x1a, 0xc0, 0x27, 0x94, | ||
147 | 0xed, 0xb7, 0x9b, 0x85, 0x0b, 0x5e, 0x80, 0x97, 0xc5, 0xec, 0x4f, 0xec, 0x88, 0x5d, 0x50, | ||
148 | 0x07, 0x35, 0x47, 0xdc, 0x0b, 0x3b, 0x3d, 0xdd, 0x60, 0xaf, 0xa8, 0x5d, 0x81, 0x38, 0x24, | ||
149 | 0x25, 0x5d, 0x5c, 0x15, 0xd1, 0xde, 0xb3, 0xab, 0xec, 0x05, 0x69, 0xef, 0x83, 0xed, 0x57, | ||
150 | 0x54, 0xb8, 0x64, 0x64, 0x11, 0x16, 0x32, 0x69, 0xda, 0x9f, 0x2d, 0x7f, 0x36, 0xbb, 0x44, | ||
151 | 0x5a, 0x34, 0xe8, 0x7f, 0xbf, 0x03, 0xeb, 0x00, 0x7f, 0x59, 0x68, 0x22, 0x79, 0xcf, 0x73, | ||
152 | 0x6c, 0x2c, 0x29, 0xa7, 0xa1, 0x5f, 0x38, 0xa1, 0x1d, 0xf0, 0x20, 0x53, 0xe0, 0x1a, 0x63, | ||
153 | 0x14, 0x58, 0x71, 0x10, 0xaa, 0x08, 0x0c, 0x3e, 0x16, 0x1a, 0x60, 0x22, 0x82, 0x7f, 0xba, | ||
154 | 0xa4, 0x43, 0xa0, 0xd0, 0xac, 0x1b, 0xd5, 0x6b, 0x64, 0xb5, 0x14, 0x93, 0x31, 0x9e, 0x53, | ||
155 | 0x50, 0xd0, 0x57, 0x66, 0xee, 0x5a, 0x4f, 0xfb, 0x03, 0x2a, 0x69, 0x58, 0x76, 0xf1, 0x83, | ||
156 | 0xf7, 0x4e, 0xba, 0x8c, 0x42, 0x06, 0x60, 0x5d, 0x6d, 0xce, 0x60, 0x88, 0xae, 0xa4, 0xc3, | ||
157 | 0xf1, 0x03, 0xa5, 0x4b, 0x98, 0xa1, 0xff, 0x67, 0xe1, 0xac, 0xa2, 0xb8, 0x62, 0xd7, 0x6f, | ||
158 | 0xa0, 0x31, 0xb4, 0xd2, 0x77, 0xaf, 0x21, 0x10, 0x06, 0xc6, 0x9a, 0xff, 0x1d, 0x09, 0x17, | ||
159 | 0x0e, 0x5f, 0xf1, 0xaa, 0x54, 0x34, 0x4b, 0x45, 0x8a, 0x87, 0x63, 0xa6, 0xdc, 0xf9, 0x24, | ||
160 | 0x30, 0x67, 0xc6, 0xb2, 0xd6, 0x61, 0x33, 0x69, 0xee, 0x50, 0x61, 0x57, 0x28, 0xe7, 0x7e, | ||
161 | 0xee, 0xec, 0x3a, 0x5a, 0x73, 0x4e, 0xa8, 0x8d, 0xe4, 0x18, 0xea, 0xec, 0x41, 0x64, 0xc8, | ||
162 | 0xe2, 0xe8, 0x66, 0xb6, 0x2d, 0xb6, 0xfb, 0x6a, 0x6c, 0x16, 0xb3, 0xdd, 0x46, 0x43, 0xb9, | ||
163 | 0x73, 0x00, 0x6a, 0x71, 0xed, 0x4e, 0x9d, 0x25, 0x1a, 0xc3, 0x3c, 0x4a, 0x95, 0x15, 0x99, | ||
164 | 0x35, 0x81, 0x14, 0x02, 0xd6, 0x98, 0x9b, 0xec, 0xd8, 0x23, 0x3b, 0x84, 0x29, 0xaf, 0x0c, | ||
165 | 0x99, 0x83, 0xa6, 0x9a, 0x34, 0x4f, 0xfa, 0xe8, 0xd0, 0x3c, 0x4b, 0xd0, 0xfb, 0xb6, 0x68, | ||
166 | 0xb8, 0x9e, 0x8f, 0xcd, 0xf7, 0x60, 0x2d, 0x7a, 0x22, 0xe5, 0x7d, 0xab, 0x65, 0x1b, 0x95, | ||
167 | 0xa7, 0xa8, 0x7f, 0xb6, 0x77, 0x47, 0x7b, 0x5f, 0x8b, 0x12, 0x72, 0xd0, 0xd4, 0x91, 0xef, | ||
168 | 0xde, 0x19, 0x50, 0x3c, 0xa7, 0x8b, 0xc4, 0xa9, 0xb3, 0x23, 0xcb, 0x76, 0xe6, 0x81, 0xf0, | ||
169 | 0xc1, 0x04, 0x8f, 0xa3, 0xb8, 0x54, 0x5b, 0x97, 0xac, 0x19, 0xff, 0x3f, 0x55, 0x27, 0x2f, | ||
170 | 0xe0, 0x1d, 0x42, 0x9b, 0x57, 0xfc, 0x4b, 0x4e, 0x0f, 0xce, 0x98, 0xa9, 0x43, 0x57, 0x03, | ||
171 | 0xbd, 0xe7, 0xc8, 0x94, 0xdf, 0x6e, 0x36, 0x73, 0x32, 0xb4, 0xef, 0x2e, 0x85, 0x7a, 0x6e, | ||
172 | 0xfc, 0x6c, 0x18, 0x82, 0x75, 0x35, 0x90, 0x07, 0xf3, 0xe4, 0x9f, 0x3e, 0xdc, 0x68, 0xf3, | ||
173 | 0xb5, 0xf3, 0x19, 0x80, 0x92, 0x06, 0x99, 0xa2, 0xe8, 0x6f, 0xff, 0x2e, 0x7f, 0xae, 0x42, | ||
174 | 0xa4, 0x5f, 0xfb, 0xd4, 0x0e, 0x81, 0x2b, 0xc3, 0x04, 0xff, 0x2b, 0xb3, 0x74, 0x4e, 0x36, | ||
175 | 0x5b, 0x9c, 0x15, 0x00, 0xc6, 0x47, 0x2b, 0xe8, 0x8b, 0x3d, 0xf1, 0x9c, 0x03, 0x9a, 0x58, | ||
176 | 0x7f, 0x9b, 0x9c, 0xbf, 0x85, 0x49, 0x79, 0x35, 0x2e, 0x56, 0x7b, 0x41, 0x14, 0x39, 0x47, | ||
177 | 0x83, 0x26, 0xaa, 0x07, 0x89, 0x98, 0x11, 0x1b, 0x86, 0xe7, 0x73, 0x7a, 0xd8, 0x7d, 0x78, | ||
178 | 0x61, 0x53, 0xe9, 0x79, 0xf5, 0x36, 0x8d, 0x44, 0x92, 0x84, 0xf9, 0x13, 0x50, 0x58, 0x3b, | ||
179 | 0xa4, 0x6a, 0x36, 0x65, 0x49, 0x8e, 0x3c, 0x0e, 0xf1, 0x6f, 0xd2, 0x84, 0xc4, 0x7e, 0x8e, | ||
180 | 0x3f, 0x39, 0xae, 0x7c, 0x84, 0xf1, 0x63, 0x37, 0x8e, 0x3c, 0xcc, 0x3e, 0x44, 0x81, 0x45, | ||
181 | 0xf1, 0x4b, 0xb9, 0xed, 0x6b, 0x36, 0x5d, 0xbb, 0x20, 0x60, 0x1a, 0x0f, 0xa3, 0xaa, 0x55, | ||
182 | 0x77, 0x3a, 0xa9, 0xae, 0x37, 0x4d, 0xba, 0xb8, 0x86, 0x6b, 0xbc, 0x08, 0x50, 0xf6, 0xcc, | ||
183 | 0xa4, 0xbd, 0x1d, 0x40, 0x72, 0xa5, 0x86, 0xfa, 0xe2, 0x10, 0xae, 0x3d, 0x58, 0x4b, 0x97, | ||
184 | 0xf3, 0x43, 0x74, 0xa9, 0x9e, 0xeb, 0x21, 0xb7, 0x01, 0xa4, 0x86, 0x93, 0x97, 0xee, 0x2f, | ||
185 | 0x4f, 0x3b, 0x86, 0xa1, 0x41, 0x6f, 0x41, 0x26, 0x90, 0x78, 0x5c, 0x7f, 0x30, 0x38, 0x4b, | ||
186 | 0x3f, 0xaa, 0xec, 0xed, 0x5c, 0x6f, 0x0e, 0xad, 0x43, 0x87, 0xfd, 0x93, 0x35, 0xe6, 0x01, | ||
187 | 0xef, 0x41, 0x26, 0x90, 0x99, 0x9e, 0xfb, 0x19, 0x5b, 0xad, 0xd2, 0x91, 0x8a, 0xe0, 0x46, | ||
188 | 0xaf, 0x65, 0xfa, 0x4f, 0x84, 0xc1, 0xa1, 0x2d, 0xcf, 0x45, 0x8b, 0xd3, 0x85, 0x50, 0x55, | ||
189 | 0x7c, 0xf9, 0x67, 0x88, 0xd4, 0x4e, 0xe9, 0xd7, 0x6b, 0x61, 0x54, 0xa1, 0xa4, 0xa6, 0xa2, | ||
190 | 0xc2, 0xbf, 0x30, 0x9c, 0x40, 0x9f, 0x5f, 0xd7, 0x69, 0x2b, 0x24, 0x82, 0x5e, 0xd9, 0xd6, | ||
191 | 0xa7, 0x12, 0x54, 0x1a, 0xf7, 0x55, 0x9f, 0x76, 0x50, 0xa9, 0x95, 0x84, 0xe6, 0x6b, 0x6d, | ||
192 | 0xb5, 0x96, 0x54, 0xd6, 0xcd, 0xb3, 0xa1, 0x9b, 0x46, 0xa7, 0x94, 0x4d, 0xc4, 0x94, 0xb4, | ||
193 | 0x98, 0xe3, 0xe1, 0xe2, 0x34, 0xd5, 0x33, 0x16, 0x07, 0x54, 0xcd, 0xb7, 0x77, 0x53, 0xdb, | ||
194 | 0x4f, 0x4d, 0x46, 0x9d, 0xe9, 0xd4, 0x9c, 0x8a, 0x36, 0xb6, 0xb8, 0x38, 0x26, 0x6c, 0x0e, | ||
195 | 0xff, 0x9c, 0x1b, 0x43, 0x8b, 0x80, 0xcc, 0xb9, 0x3d, 0xda, 0xc7, 0xf1, 0x8a, 0xf2, 0x6d, | ||
196 | 0xb8, 0xd7, 0x74, 0x2f, 0x7e, 0x1e, 0xb7, 0xd3, 0x4a, 0xb4, 0xac, 0xfc, 0x79, 0x48, 0x6c, | ||
197 | 0xbc, 0x96, 0xb6, 0x94, 0x46, 0x57, 0x2d, 0xb0, 0xa3, 0xfc, 0x1e, 0xb9, 0x52, 0x60, 0x85, | ||
198 | 0x2d, 0x41, 0xd0, 0x43, 0x01, 0x1e, 0x1c, 0xd5, 0x7d, 0xfc, 0xf3, 0x96, 0x0d, 0xc7, 0xcb, | ||
199 | 0x2a, 0x29, 0x9a, 0x93, 0xdd, 0x88, 0x2d, 0x37, 0x5d, 0xaa, 0xfb, 0x49, 0x68, 0xa0, 0x9c, | ||
200 | 0x50, 0x86, 0x7f, 0x68, 0x56, 0x57, 0xf9, 0x79, 0x18, 0x39, 0xd4, 0xe0, 0x01, 0x84, 0x33, | ||
201 | 0x61, 0xca, 0xa5, 0xd2, 0xd6, 0xe4, 0xc9, 0x8a, 0x4a, 0x23, 0x44, 0x4e, 0xbc, 0xf0, 0xdc, | ||
202 | 0x24, 0xa1, 0xa0, 0xc4, 0xe2, 0x07, 0x3c, 0x10, 0xc4, 0xb5, 0x25, 0x4b, 0x65, 0x63, 0xf4, | ||
203 | 0x80, 0xe7, 0xcf, 0x61, 0xb1, 0x71, 0x82, 0x21, 0x87, 0x2c, 0xf5, 0x91, 0x00, 0x32, 0x0c, | ||
204 | 0xec, 0xa9, 0xb5, 0x9a, 0x74, 0x85, 0xe3, 0x36, 0x8f, 0x76, 0x4f, 0x9c, 0x6d, 0xce, 0xbc, | ||
205 | 0xad, 0x0a, 0x4b, 0xed, 0x76, 0x04, 0xcb, 0xc3, 0xb9, 0x33, 0x9e, 0x01, 0x93, 0x96, 0x69, | ||
206 | 0x7d, 0xc5, 0xa2, 0x45, 0x79, 0x9b, 0x04, 0x5c, 0x84, 0x09, 0xed, 0x88, 0x43, 0xc7, 0xab, | ||
207 | 0x93, 0x14, 0x26, 0xa1, 0x40, 0xb5, 0xce, 0x4e, 0xbf, 0x2a, 0x42, 0x85, 0x3e, 0x2c, 0x3b, | ||
208 | 0x54, 0xe8, 0x12, 0x1f, 0x0e, 0x97, 0x59, 0xb2, 0x27, 0x89, 0xfa, 0xf2, 0xdf, 0x8e, 0x68, | ||
209 | 0x59, 0xdc, 0x06, 0xbc, 0xb6, 0x85, 0x0d, 0x06, 0x22, 0xec, 0xb1, 0xcb, 0xe5, 0x04, 0xe6, | ||
210 | 0x3d, 0xb3, 0xb0, 0x41, 0x73, 0x08, 0x3f, 0x3c, 0x58, 0x86, 0x63, 0xeb, 0x50, 0xee, 0x1d, | ||
211 | 0x2c, 0x37, 0x74, 0xa9, 0xd3, 0x18, 0xa3, 0x47, 0x6e, 0x93, 0x54, 0xad, 0x0a, 0x5d, 0xb8, | ||
212 | 0x2a, 0x55, 0x5d, 0x78, 0xf6, 0xee, 0xbe, 0x8e, 0x3c, 0x76, 0x69, 0xb9, 0x40, 0xc2, 0x34, | ||
213 | 0xec, 0x2a, 0xb9, 0xed, 0x7e, 0x20, 0xe4, 0x8d, 0x00, 0x38, 0xc7, 0xe6, 0x8f, 0x44, 0xa8, | ||
214 | 0x86, 0xce, 0xeb, 0x2a, 0xe9, 0x90, 0xf1, 0x4c, 0xdf, 0x32, 0xfb, 0x73, 0x1b, 0x6d, 0x92, | ||
215 | 0x1e, 0x95, 0xfe, 0xb4, 0xdb, 0x65, 0xdf, 0x4d, 0x23, 0x54, 0x89, 0x48, 0xbf, 0x4a, 0x2e, | ||
216 | 0x70, 0xd6, 0xd7, 0x62, 0xb4, 0x33, 0x29, 0xb1, 0x3a, 0x33, 0x4c, 0x23, 0x6d, 0xa6, 0x76, | ||
217 | 0xa5, 0x21, 0x63, 0x48, 0xe6, 0x90, 0x5d, 0xed, 0x90, 0x95, 0x0b, 0x7a, 0x84, 0xbe, 0xb8, | ||
218 | 0x0d, 0x5e, 0x63, 0x0c, 0x62, 0x26, 0x4c, 0x14, 0x5a, 0xb3, 0xac, 0x23, 0xa4, 0x74, 0xa7, | ||
219 | 0x6f, 0x33, 0x30, 0x05, 0x60, 0x01, 0x42, 0xa0, 0x28, 0xb7, 0xee, 0x19, 0x38, 0xf1, 0x64, | ||
220 | 0x80, 0x82, 0x43, 0xe1, 0x41, 0x27, 0x1f, 0x1f, 0x90, 0x54, 0x7a, 0xd5, 0x23, 0x2e, 0xd1, | ||
221 | 0x3d, 0xcb, 0x28, 0xba, 0x58, 0x7f, 0xdc, 0x7c, 0x91, 0x24, 0xe9, 0x28, 0x51, 0x83, 0x6e, | ||
222 | 0xc5, 0x56, 0x21, 0x42, 0xed, 0xa0, 0x56, 0x22, 0xa1, 0x40, 0x80, 0x6b, 0xa8, 0xf7, 0x94, | ||
223 | 0xca, 0x13, 0x6b, 0x0c, 0x39, 0xd9, 0xfd, 0xe9, 0xf3, 0x6f, 0xa6, 0x9e, 0xfc, 0x70, 0x8a, | ||
224 | 0xb3, 0xbc, 0x59, 0x3c, 0x1e, 0x1d, 0x6c, 0xf9, 0x7c, 0xaf, 0xf9, 0x88, 0x71, 0x95, 0xeb, | ||
225 | 0x57, 0x00, 0xbd, 0x9f, 0x8c, 0x4f, 0xe1, 0x24, 0x83, 0xc5, 0x22, 0xea, 0xfd, 0xd3, 0x0c, | ||
226 | 0xe2, 0x17, 0x18, 0x7c, 0x6a, 0x4c, 0xde, 0x77, 0xb4, 0x53, 0x9b, 0x4c, 0x81, 0xcd, 0x23, | ||
227 | 0x60, 0xaa, 0x0e, 0x25, 0x73, 0x9c, 0x02, 0x79, 0x32, 0x30, 0xdf, 0x74, 0xdf, 0x75, 0x19, | ||
228 | 0xf4, 0xa5, 0x14, 0x5c, 0xf7, 0x7a, 0xa8, 0xa5, 0x91, 0x84, 0x7c, 0x60, 0x03, 0x06, 0x3b, | ||
229 | 0xcd, 0x50, 0xb6, 0x27, 0x9c, 0xfe, 0xb1, 0xdd, 0xcc, 0xd3, 0xb0, 0x59, 0x24, 0xb2, 0xca, | ||
230 | 0xe2, 0x1c, 0x81, 0x22, 0x9d, 0x07, 0x8f, 0x8e, 0xb9, 0xbe, 0x4e, 0xfa, 0xfc, 0x39, 0x65, | ||
231 | 0xba, 0xbf, 0x9d, 0x12, 0x37, 0x5e, 0x97, 0x7e, 0xf3, 0x89, 0xf5, 0x5d, 0xf5, 0xe3, 0x09, | ||
232 | 0x8c, 0x62, 0xb5, 0x20, 0x9d, 0x0c, 0x53, 0x8a, 0x68, 0x1b, 0xd2, 0x8f, 0x75, 0x17, 0x5d, | ||
233 | 0xd4, 0xe5, 0xda, 0x75, 0x62, 0x19, 0x14, 0x6a, 0x26, 0x2d, 0xeb, 0xf8, 0xaf, 0x37, 0xf0, | ||
234 | 0x6c, 0xa4, 0x55, 0xb1, 0xbc, 0xe2, 0x33, 0xc0, 0x9a, 0xca, 0xb0, 0x11, 0x49, 0x4f, 0x68, | ||
235 | 0x9b, 0x3b, 0x6b, 0x3c, 0xcc, 0x13, 0xf6, 0xc7, 0x85, 0x61, 0x68, 0x42, 0xae, 0xbb, 0xdd, | ||
236 | 0xcd, 0x45, 0x16, 0x29, 0x1d, 0xea, 0xdb, 0xc8, 0x03, 0x94, 0x3c, 0xee, 0x4f, 0x82, 0x11, | ||
237 | 0xc3, 0xec, 0x28, 0xbd, 0x97, 0x05, 0x99, 0xde, 0xd7, 0xbb, 0x5e, 0x22, 0x1f, 0xd4, 0xeb, | ||
238 | 0x64, 0xd9, 0x92, 0xd9, 0x85, 0xb7, 0x6a, 0x05, 0x6a, 0xe4, 0x24, 0x41, 0xf1, 0xcd, 0xf0, | ||
239 | 0xd8, 0x3f, 0xf8, 0x9e, 0x0e, 0xcd, 0x0b, 0x7a, 0x70, 0x6b, 0x5a, 0x75, 0x0a, 0x6a, 0x33, | ||
240 | 0x88, 0xec, 0x17, 0x75, 0x08, 0x70, 0x10, 0x2f, 0x24, 0xcf, 0xc4, 0xe9, 0x42, 0x00, 0x61, | ||
241 | 0x94, 0xca, 0x1f, 0x3a, 0x76, 0x06, 0xfa, 0xd2, 0x48, 0x81, 0xf0, 0x77, 0x60, 0x03, 0x45, | ||
242 | 0xd9, 0x61, 0xf4, 0xa4, 0x6f, 0x3d, 0xd9, 0x30, 0xc3, 0x04, 0x6b, 0x54, 0x2a, 0xb7, 0xec, | ||
243 | 0x3b, 0xf4, 0x4b, 0xf5, 0x68, 0x52, 0x26, 0xce, 0xff, 0x5d, 0x19, 0x91, 0xa0, 0xa3, 0xa5, | ||
244 | 0xa9, 0xb1, 0xe0, 0x23, 0xc4, 0x0a, 0x77, 0x4d, 0xf9, 0x51, 0x20, 0xa3, 0xa5, 0xa9, 0xb1, | ||
245 | 0xc1, 0x00, 0x82, 0x86, 0x8e, 0x7f, 0x5d, 0x19, 0x91, 0xa0, 0xa3, 0xc4, 0xeb, 0x54, 0x0b, | ||
246 | 0x75, 0x68, 0x52, 0x07, 0x8c, 0x9a, 0x97, 0x8d, 0x79, 0x70, 0x62, 0x46, 0xef, 0x5c, 0x1b, | ||
247 | 0x95, 0x89, 0x71, 0x41, 0xe1, 0x21, 0xa1, 0xa1, 0xa1, 0xc0, 0x02, 0x67, 0x4c, 0x1a, 0xb6, | ||
248 | 0xcf, 0xfd, 0x78, 0x53, 0x24, 0xab, 0xb5, 0xc9, 0xf1, 0x60, 0x23, 0xa5, 0xc8, 0x12, 0x87, | ||
249 | 0x6d, 0x58, 0x13, 0x85, 0x88, 0x92, 0x87, 0x6d, 0x58, 0x32, 0xc7, 0x0c, 0x9a, 0x97, 0xac, | ||
250 | 0xda, 0x36, 0xee, 0x5e, 0x3e, 0xdf, 0x1d, 0xb8, 0xf2, 0x66, 0x2f, 0xbd, 0xf8, 0x72, 0x47, | ||
251 | 0xed, 0x58, 0x13, 0x85, 0x88, 0x92, 0x87, 0x8c, 0x7b, 0x55, 0x09, 0x90, 0xa2, 0xc6, 0xef, | ||
252 | 0x3d, 0xf8, 0x53, 0x24, 0xab, 0xd4, 0x2a, 0xb7, 0xec, 0x5a, 0x36, 0xee, 0x5e, 0x3e, 0xdf, | ||
253 | 0x3c, 0xfa, 0x76, 0x4f, 0xfd, 0x59, 0x30, 0xe2, 0x46, 0xef, 0x3d, 0xf8, 0x53, 0x05, 0x69, | ||
254 | 0x31, 0xc1, 0x00, 0x82, 0x86, 0x8e, 0x7f, 0x5d, 0x19, 0xb0, 0xe2, 0x27, 0xcc, 0xfb, 0x74, | ||
255 | 0x4b, 0x14, 0x8b, 0x94, 0x8b, 0x75, 0x68, 0x33, 0xc5, 0x08, 0x92, 0x87, 0x8c, 0x9a, 0xb6, | ||
256 | 0xcf, 0x1c, 0xba, 0xd7, 0x0d, 0x98, 0xb2, 0xe6, 0x2f, 0xdc, 0x1b, 0x95, 0x89, 0x71, 0x60, | ||
257 | 0x23, 0xc4, 0x0a, 0x96, 0x8f, 0x9c, 0xba, 0xf6, 0x6e, 0x3f, 0xfc, 0x5b, 0x15, 0xa8, 0xd2, | ||
258 | 0x26, 0xaf, 0xbd, 0xf8, 0x72, 0x66, 0x2f, 0xdc, 0x1b, 0xb4, 0xcb, 0x14, 0x8b, 0x94, 0xaa, | ||
259 | 0xb7, 0xcd, 0xf9, 0x51, 0x01, 0x80, 0x82, 0x86, 0x6f, 0x3d, 0xd9, 0x30, 0xe2, 0x27, 0xcc, | ||
260 | 0xfb, 0x74, 0x4b, 0x14, 0xaa, 0xb7, 0xcd, 0xf9, 0x70, 0x43, 0x04, 0x6b, 0x35, 0xc9, 0xf1, | ||
261 | 0x60, 0x23, 0xa5, 0xc8, 0xf3, 0x45, 0x08, 0x92, 0x87, 0x6d, 0x58, 0x32, 0xe6, 0x2f, 0xbd, | ||
262 | 0xf8, 0x72, 0x66, 0x4e, 0x1e, 0xbe, 0xfe, 0x7e, 0x7e, 0x7e, 0x5f, 0x1d, 0x99, 0x91, 0xa0, | ||
263 | 0xa3, 0xc4, 0x0a, 0x77, 0x4d, 0x18, 0x93, 0xa4, 0xab, 0xd4, 0x0b, 0x75, 0x49, 0x10, 0xa2, | ||
264 | 0xc6, 0xef, 0x3d, 0xf8, 0x53, 0x24, 0xab, 0xb5, 0xe8, 0x33, 0xe4, 0x4a, 0x16, 0xae, 0xde, | ||
265 | 0x1f, 0xbc, 0xdb, 0x15, 0xa8, 0xb3, 0xc5, 0x08, 0x73, 0x45, 0xe9, 0x31, 0xc1, 0xe1, 0x21, | ||
266 | 0xa1, 0xa1, 0xa1, 0xc0, 0x02, 0x86, 0x6f, 0x5c, 0x3a, 0xd7, 0x0d, 0x98, 0x93, 0xa4, 0xca, | ||
267 | 0x16, 0xae, 0xde, 0x1f, 0x9d, 0x99, 0xb0, 0xe2, 0x46, 0xef, 0x3d, 0xf8, 0x72, 0x47, 0x0c, | ||
268 | 0x9a, 0xb6, 0xcf, 0xfd, 0x59, 0x11, 0xa0, 0xa3, 0xa5, 0xc8, 0xf3, 0x45, 0x08, 0x92, 0x87, | ||
269 | 0x6d, 0x39, 0xf0, 0x43, 0x04, 0x8a, 0x96, 0xae, 0xde, 0x3e, 0xdf, 0x1d, 0x99, 0x91, 0xa0, | ||
270 | 0xc2, 0x06, 0x6f, 0x3d, 0xf8, 0x72, 0x47, 0x0c, 0x9a, 0x97, 0x8d, 0x98, 0x93, 0x85, 0x88, | ||
271 | 0x73, 0x45, 0xe9, 0x31, 0xe0, 0x23, 0xa5, 0xa9, 0xd0, 0x03, 0x84, 0x8a, 0x96, 0xae, 0xde, | ||
272 | 0x1f, 0xbc, 0xdb, 0x15, 0xa8, 0xd2, 0x26, 0xce, 0xff, 0x5d, 0x19, 0x91, 0x81, 0x80, 0x82, | ||
273 | 0x67, 0x2d, 0xd8, 0x13, 0xa4, 0xab, 0xd4, 0x0b, 0x94, 0xaa, 0xb7, 0xcd, 0xf9, 0x51, 0x20, | ||
274 | 0xa3, 0xa5, 0xc8, 0xf3, 0x45, 0xe9, 0x50, 0x22, 0xc6, 0xef, 0x5c, 0x3a, 0xd7, 0x0d, 0x98, | ||
275 | 0x93, 0x85, 0x88, 0x73, 0x64, 0x4a, 0xf7, 0x4d, 0xf9, 0x51, 0x20, 0xa3, 0xc4, 0x0a, 0x96, | ||
276 | 0xae, 0xde, 0x3e, 0xfe, 0x7e, 0x7e, 0x7e, 0x5f, 0x3c, 0xfa, 0x76, 0x4f, 0xfd, 0x78, 0x72, | ||
277 | 0x66, 0x2f, 0xbd, 0xd9, 0x30, 0xc3, 0xe5, 0x48, 0x12, 0x87, 0x8c, 0x7b, 0x55, 0x28, 0xd2, | ||
278 | 0x07, 0x8c, 0x9a, 0x97, 0xac, 0xda, 0x17, 0x8d, 0x79, 0x51, 0x20, 0xa3, 0xc4, 0xeb, 0x54, | ||
279 | 0x0b, 0x94, 0x8b, 0x94, 0xaa, 0xd6, 0x2e, 0xbf, 0xfc, 0x5b, 0x15, 0xa8, 0xd2, 0x26, 0xaf, | ||
280 | 0xdc, 0x1b, 0xb4, 0xea, 0x37, 0xec, 0x3b, 0xf4, 0x6a, 0x37, 0xcd, 0x18, 0x93, 0x85, 0x69, | ||
281 | 0x31, 0xc1, 0xe1, 0x40, 0xe3, 0x25, 0xc8, 0x12, 0x87, 0x8c, 0x9a, 0xb6, 0xcf, 0xfd, 0x59, | ||
282 | 0x11, 0xa0, 0xc2, 0x06, 0x8e, 0x7f, 0x5d, 0x38, 0xf2, 0x47, 0x0c, 0x7b, 0x74, 0x6a, 0x37, | ||
283 | 0xec, 0x5a, 0x36, 0xee, 0x3f, 0xfc, 0x7a, 0x76, 0x4f, 0x1c, 0x9b, 0x95, 0x89, 0x71, 0x41, | ||
284 | 0x00, 0x63, 0x44, 0xeb, 0x54, 0x2a, 0xd6, 0x0f, 0x9c, 0xba, 0xd7, 0x0d, 0x98, 0x93, 0x85, | ||
285 | 0x69, 0x31, 0xc1, 0x00, 0x82, 0x86, 0x8e, 0x9e, 0xbe, 0xdf, 0x3c, 0xfa, 0x57, 0x2c, 0xda, | ||
286 | 0x36, 0xee, 0x3f, 0xfc, 0x5b, 0x15, 0x89, 0x71, 0x41, 0x00, 0x82, 0x86, 0x8e, 0x7f, 0x5d, | ||
287 | 0x38, 0xf2, 0x47, 0xed, 0x58, 0x13, 0xa4, 0xca, 0xf7, 0x4d, 0xf9, 0x51, 0x01, 0x80, 0x63, | ||
288 | 0x44, 0xeb, 0x54, 0x2a, 0xd6, 0x2e, 0xbf, 0xdd, 0x19, 0x91, 0xa0, 0xa3, 0xa5, 0xa9, 0xb1, | ||
289 | 0xe0, 0x42, 0x06, 0x8e, 0x7f, 0x5d, 0x19, 0x91, 0xa0, 0xa3, 0xc4, 0x0a, 0x96, 0x8f, 0x7d, | ||
290 | 0x78, 0x72, 0x47, 0x0c, 0x7b, 0x74, 0x6a, 0x56, 0x2e, 0xde, 0x1f, 0xbc, 0xfa, 0x57, 0x0d, | ||
291 | 0x79, 0x51, 0x01, 0x61, 0x21, 0xa1, 0xc0, 0xe3, 0x25, 0xa9, 0xb1, 0xc1, 0xe1, 0x40, 0x02, | ||
292 | 0x67, 0x4c, 0x1a, 0x97, 0x8d, 0x98, 0x93, 0xa4, 0xab, 0xd4, 0x2a, 0xd6, 0x0f, 0x9c, 0x9b, | ||
293 | 0xb4, 0xcb, 0x14, 0xaa, 0xb7, 0xcd, 0xf9, 0x51, 0x20, 0xa3, 0xc4, 0xeb, 0x35, 0xc9, 0xf1, | ||
294 | 0x60, 0x42, 0x06, 0x8e, 0x7f, 0x7c, 0x7a, 0x76, 0x6e, 0x3f, 0xfc, 0x7a, 0x76, 0x6e, 0x5e, | ||
295 | 0x3e, 0xfe, 0x7e, 0x5f, 0x3c, 0xdb, 0x15, 0x89, 0x71, 0x41, 0xe1, 0x21, 0xc0, 0xe3, 0x44, | ||
296 | 0xeb, 0x54, 0x2a, 0xb7, 0xcd, 0xf9, 0x70, 0x62, 0x27, 0xad, 0xd8, 0x32, 0xc7, 0x0c, 0x7b, | ||
297 | 0x74, 0x4b, 0x14, 0xaa, 0xb7, 0xec, 0x3b, 0xd5, 0x28, 0xd2, 0x07, 0x6d, 0x39, 0xd1, 0x20, | ||
298 | 0xc2, 0xe7, 0x4c, 0x1a, 0x97, 0x8d, 0x98, 0xb2, 0xc7, 0x0c, 0x59, 0x28, 0xf3, 0x9b }; | ||
299 | |||
300 | // clang-format off | ||
diff --git a/drivers/serial.h b/drivers/serial.h new file mode 100644 index 000000000..d9c2a69e9 --- /dev/null +++ b/drivers/serial.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* Copyright 2021 QMK | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #pragma once | ||
18 | |||
19 | #include <stdint.h> | ||
20 | #include <stdbool.h> | ||
21 | |||
22 | #include <transactions.h> | ||
23 | |||
24 | // initiator is transaction start side | ||
25 | void soft_serial_initiator_init(void); | ||
26 | // target is interrupt accept side | ||
27 | void soft_serial_target_init(void); | ||
28 | |||
29 | // initiator result | ||
30 | #define TRANSACTION_END 0 | ||
31 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
32 | #define TRANSACTION_DATA_ERROR 0x2 | ||
33 | #define TRANSACTION_TYPE_ERROR 0x4 | ||
34 | int soft_serial_transaction(int sstd_index); | ||
35 | |||
36 | // target status | ||
37 | // *SSTD_t.status has | ||
38 | // initiator: | ||
39 | // TRANSACTION_END | ||
40 | // or TRANSACTION_NO_RESPONSE | ||
41 | // or TRANSACTION_DATA_ERROR | ||
42 | // target: | ||
43 | // TRANSACTION_DATA_ERROR | ||
44 | // or TRANSACTION_ACCEPTED | ||
45 | #define TRANSACTION_ACCEPTED 0x8 | ||
46 | int soft_serial_get_and_clean_status(int sstd_index); | ||