tommy писал(а):
и, кстати, раз строки всё одно фиксированные, то можно юзать не буффер символов, а буфер указателей на строки/идентификаторов строки. даж если часть строки фиксированная, а другая нет, то всё одно, сделать смесь символ/строка и будет огромный выйгрыш в памяти (этих 17 символов за глаза хватит).
Длинна строк разная, но работаю именно через указатели.
Сами строки лежат в памяти программ.
Код:
const unsigned char command_0[] PROGMEM = "bullets_in_clip="; //
const unsigned char command_1[] PROGMEM = "bullets_in_clip?"; //
const unsigned char command_2[] PROGMEM = "protocol?";
const unsigned char command_3[] PROGMEM = "clips="; //
const unsigned char command_4[] PROGMEM = "clips?"; //
const unsigned char command_5[] PROGMEM = "prepare_to_write_block";
const unsigned char command_6[] PROGMEM = "read_block";
const unsigned char command_7[] PROGMEM = "sound_1_adress=";
const unsigned char command_8[] PROGMEM = "sound_1_adress?";
const unsigned char command_9[] PROGMEM = "sound_1_size=";
const unsigned char command_10[] PROGMEM = "sound_1_size?";
const unsigned char command_11[] PROGMEM = "sound_2_adress=";
const unsigned char command_12[] PROGMEM = "sound_2_adress?";
const unsigned char command_13[] PROGMEM = "sound_2_size=";
const unsigned char command_14[] PROGMEM = "sound_2_size?";
const unsigned char command_15[] PROGMEM = "sound_3_adress=";
const unsigned char command_16[] PROGMEM = "sound_3_adress?";
const unsigned char command_17[] PROGMEM = "sound_3_size=";
const unsigned char command_18[] PROGMEM = "sound_3_size?";
const unsigned char command_19[] PROGMEM = "sound_4_adress=";
const unsigned char command_20[] PROGMEM = "sound_4_adress?";
const unsigned char command_21[] PROGMEM = "sound_4_size=";
const unsigned char command_22[] PROGMEM = "sound_4_size?";
const unsigned char command_23[] PROGMEM = "sound_5_adress=";
const unsigned char command_24[] PROGMEM = "sound_5_adress?";
const unsigned char command_25[] PROGMEM = "sound_5_size=";
const unsigned char command_26[] PROGMEM = "sound_5_size?";
const unsigned char command_27[] PROGMEM = "sound_6_adress=";
const unsigned char command_28[] PROGMEM = "sound_6_adress?";
const unsigned char command_29[] PROGMEM = "sound_6_size=";
const unsigned char command_30[] PROGMEM = "sound_6_size?";
const unsigned char command_31[] PROGMEM = "play_sound";
const unsigned char command_32[] PROGMEM = "play_shot_sound";
const unsigned char* commandsPointers[] PROGMEM =
{command_0,
command_1,
command_2,
command_3,
command_4,
command_5,
command_6,
command_7,
command_8,
command_9,
command_10,
command_11,
command_12,
command_13,
command_14,
command_15,
command_16,
command_17,
command_18,
command_19,
command_20,
command_21,
command_22,
command_23,
command_24,
command_25,
command_26,
command_27,
command_28,
command_29,
command_30,
command_31,
command_32
};
const unsigned char unknown_command_error[] PROGMEM = "ERROR:unknown command\r\n";
const unsigned char parameter_empty_error[] PROGMEM = "ERROR:parameter is not specified\r\n";
const unsigned char parameter_out_of_range_error[] PROGMEM = "ERROR:parameter out of range\r\n";
const unsigned char protocol[] PROGMEM = "bullets_in_clip;int(0,90);bullets_in_clip?;bullets_in_clip=\r\nclips;int(0,100);clips?;clips=\r\n";
И, кажется, догодался, в чём косяк - прерывание, похоже, не верно названно
Код:
//обработчик прерывания по завершению передачи
ISR(USART_TX_vect)
{
if (txCount > 0){ //если буфер не пустой
UDR = usartTxBuf[txBufHead]; //записываем в UDR символ из буфера
txCount--; //уменьшаем счетчик символов
txBufHead++; //инкрементируем индекс головы буфера
if (txBufHead == SIZE_BUF) txBufHead = 0;
}
}
А должно быть для 32 меги
ISR(USART_TXС_vect)По приему символа я исправлял, а это мог и не переименовать, хотя точно не помню...
В понедельник проверю!