Commit d88e8125 authored by Markéta Jedličková's avatar Markéta Jedličková
Browse files

Interrupts added

parent 241a8c81
......@@ -1199,7 +1199,7 @@ static int16_t ucg_com_arduino_4wire_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t ar
/* setup Arduino SPI */
SPI.usingInterrupt(ucg->pin_list[UCG_PIN_CS]);
SPI.begin();
SPI.beginTransaction(SPISettings(1000000000UL/((ucg_com_info_t *)data)->serial_clk_speed, MSBFIRST, SPI_MODE0));
......@@ -1217,6 +1217,7 @@ static int16_t ucg_com_arduino_4wire_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t ar
case UCG_COM_MSG_POWER_DOWN:
SPI.endTransaction();
SPI.end();
break;
case UCG_COM_MSG_DELAY:
delayMicroseconds(arg);
......@@ -1236,33 +1237,42 @@ static int16_t ucg_com_arduino_4wire_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t ar
SPI.transfer(arg);
break;
case UCG_COM_MSG_REPEAT_1_BYTE:
noInterrupts();
while( arg > 0 ) {
SPI.transfer(data[0]);
arg--;
}
interrupts();
break;
case UCG_COM_MSG_REPEAT_2_BYTES:
noInterrupts();
while( arg > 0 ) {
SPI.transfer(data[0]);
SPI.transfer(data[1]);
arg--;
}
interrupts();
break;
case UCG_COM_MSG_REPEAT_3_BYTES:
noInterrupts();
while( arg > 0 ) {
SPI.transfer(data[0]);
SPI.transfer(data[1]);
SPI.transfer(data[2]);
arg--;
}
interrupts();
break;
case UCG_COM_MSG_SEND_STR:
noInterrupts();
while( arg > 0 ) {
SPI.transfer(*data++);
arg--;
}
interrupts();
break;
case UCG_COM_MSG_SEND_CD_DATA_SEQUENCE:
noInterrupts();
while(arg > 0)
{
if ( *data != 0 )
......@@ -1282,6 +1292,7 @@ static int16_t ucg_com_arduino_4wire_HW_SPI(ucg_t *ucg, int16_t msg, uint16_t ar
data++;
arg--;
}
interrupts();
break;
}
return 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment