a little progress
This commit is contained in:
parent
f60166c1a1
commit
3c0d86eb47
@ -53,7 +53,7 @@ char initialReplyBody[50] = "Initial reply"; // 'Status' response if read
|
||||
uint32_t messageCounter = 0; /* Counts number of messages received to return as part of response */
|
||||
|
||||
uint8_t rxBody[240]; /* stores last message master sent us (intentionally a few bytes smaller than txBody) */
|
||||
uint8_t txBody[256]; /* Return message buffer for computed replies */
|
||||
uint8_t txBody[MATRIX_ROWS/2]; /* Return message buffer for computed replies */
|
||||
|
||||
BaseSequentialStream *chp = NULL; // Used for serial logging
|
||||
|
||||
@ -126,19 +126,12 @@ const char hexString[16] = "0123456789abcdef";
|
||||
* Note: Called in interrupt context, so need to be quick!
|
||||
*/
|
||||
void twi2c_slave_message_process(I2CDriver *i2cp) {
|
||||
uint8_t *txPtr = txBody;
|
||||
uint8_t txLen;
|
||||
|
||||
size_t len = i2cSlaveBytes(i2cp); // Number of bytes received
|
||||
// size_t len = i2cSlaveBytes(i2cp); // Number of bytes received
|
||||
|
||||
if (len >= 2 && rxBody[0] == 0x01 && rxBody[1] == 0x00) {
|
||||
matrix_row_t matrix[MATRIX_ROWS / 2];
|
||||
matrix_copy(matrix);
|
||||
memcpy(txPtr, matrix, MATRIX_ROWS / 2);
|
||||
txLen = MATRIX_ROWS / 2;
|
||||
}
|
||||
matrix_copy(txBody);
|
||||
|
||||
echoReply.size = txLen;
|
||||
echoReply.size = MATRIX_ROWS / 2;
|
||||
i2cSlaveReplyI(i2cp, &echoReply);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,8 @@ void matrix_init(void) {
|
||||
right_hand = palReadPad(GPIOC, 13);
|
||||
|
||||
// if USB is active, this is the master
|
||||
master = (USB_DRIVER.state == USB_ACTIVE);
|
||||
// master = usbGetDriverStateI(&USB_DRIVER) == USB_ACTIVE;
|
||||
master = right_hand;
|
||||
|
||||
if (master) {
|
||||
twi2c_master_init();
|
||||
@ -127,15 +128,16 @@ matrix_row_t matrix_scan_common(uint8_t row) {
|
||||
return data;
|
||||
}
|
||||
|
||||
const uint8_t command[2] = { 0x01, 0x00 };
|
||||
uint8_t other_matrix[MATRIX_ROWS] = { 0 };
|
||||
|
||||
void matrix_scan_master(void) {
|
||||
|
||||
const uint8_t command[2] = { 0x01, 0x00 };
|
||||
uint8_t other_matrix[MATRIX_ROWS];
|
||||
|
||||
msg_t resp;
|
||||
resp = twi2c_master_send(slaveI2Caddress/2, command, other_matrix, TIME_INFINITE);
|
||||
printf("%x\n", resp);
|
||||
resp = twi2c_master_send(slaveI2Caddress/2, command, other_matrix, TIME_IMMEDIATE);
|
||||
// printf("%x\n", resp);
|
||||
|
||||
if (resp == MSG_OK) {
|
||||
uint8_t * matrix_pointer;
|
||||
if (right_hand) {
|
||||
matrix_pointer = matrix;
|
||||
@ -144,6 +146,7 @@ void matrix_scan_master(void) {
|
||||
}
|
||||
|
||||
memcpy(matrix_pointer, other_matrix, MATRIX_ROWS / 2);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t matrix_scan(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user