void send_data (void) { int num; char new_mas[pack_len]; int i = 0; int go; num = read_max(2, 0x100); new_mas[0] = read_max(2, 0x102); new_mas[pack_len - 1] = read_max(2, 0x103); send_first(num); while (i < num) { new_mas[1] = read_max(2, 0x10 + i); i++; new_mas[2] = read_max(2, 0x10 + i); i++; for (go = 0; go < pack_len; go++) { TI = 0; SBUF = new_mas[go]; while(!TI); } } send_end(num); }
void send_first (int nume) { int go; new_mas[0] = read_max(2, 0x102); new_mas[pack_len - 1] = read_max(2, 0x103); new_mas[1] = 0x30; new_mas[2] = nume + 0x30; for (go = 0; go < pack_len; go++) { TI = 0; SBUF = new_mas[go]; while(!TI); } }
unsigned char lcd_getDdramAddress(void) { unsigned char retval = 0x00; write_max(C_IND, 0x03); // RS=0 RW=1 E=1 retval = read_max(DATA_IND); write_max(C_IND, 0x02); // RS=0 RW=1 E=0 retval = retval & 0x7f; return retval; }
/** * Значение BF * * Функция возвращает значение флага занятости - BF */ unsigned char lcd_bfstate() { unsigned char retval = 0x00; write_max(C_IND_ADDR, 0x03); /* RS=0 RW=1 E=1 */ retval = read_max(DATA_IND_ADDR); write_max(C_IND_ADDR, 0x02); /* RS=0 RW=1 E=0 */ retval = retval >> 7; return retval; }
unsigned char lcd_getBusyFlagState(void) { //get busy flag unsigned char retval = 0x00; write_max(C_IND, 0x03); // RS=0 RW=1 E=1 retval = read_max(DATA_IND); write_max(C_IND, 0x02); // RS=0 RW=1 E=0 retval = retval >> 7; return retval; }
void send_end (int nume) { int go; new_mas[0] = read_max(2, 0x102); new_mas[pack_len - 1] = read_max(2, 0x103); new_mas[1] = crc8(2, 0x10, nume); new_mas[2] = 0x41; for (go = 0; go < pack_len; go++) { TI = 0; SBUF = new_mas[go]; while(!TI); } TI = 0; SBUF = 10; while(!TI); }
static void scan_col(uint8_t col) { uint8_t row; uint8_t kb_reg; select_col(col); kb_reg = read_max(KB); write_max(KB, 0); for (row = 0; row < 4; row++) update_key(col, row, kb_reg); }
/////////////////////////////////////////////////////////////////////////////// ///\brief Main program /// /// Initialize the simualtion and read input data from SCI,run the simulations, /// and write the results /// /// ///\return void No return needed /////////////////////////////////////////////////////////////////////////////// int main() { para.geom = &geom; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; initial(¶); if(!read_max(¶, var)) { printf("no file"); exit(1); } if(!allocate_data( )) exit ( 1 ); clear_data(¶, var,BINDEX); if(!read_input(¶, var,BINDEX)) { printf("no file"); exit(1); } init_data(¶, var,BINDEX); mark_cell(¶, var,BINDEX); if(para.solv->read_file==1) read_data(¶,var); FFD_solver(¶, var,BINDEX); write_SCI(¶, var, "output"); free_data(var); free_index(BINDEX); //getchar(); exit ( 0 ); } // End of main( )
int recieve_string (void) { unsigned char start, stop; unsigned char buff; unsigned int i = 0; unsigned short kol_vo_not; unsigned char good_or_bad; unsigned char num_page; start = read_max(2, 0x102); stop = read_max(2, 0x103); buff = SBUF; RI = 0; if (!if_ri()) return 0; buff = SBUF; RI = 0; if (!(buff & 0x80)) { good_or_bad = buff & 0x40; kol_vo_not = (buff & 0x3f) << 8; if (!if_ri()) return 0; buff = SBUF; RI = 0; kol_vo_not += buff; while (kol_vo_not) { if (!if_ri()) return 0; buff = SBUF; RI = 0; if ((buff != start) && (buff != stop)) { write_max(4, 0x102+i, buff); i++; kol_vo_not--; } } write_max(4, 0x102+i, 0); if (good_or_bad) { num_page = 5; is_good_melody = 1; } else { num_page = 6; is_bad_melody = 1; } init_timer(); str_to_notes (num_page); play_melody (num_page); init_uart(); } else { init_timer(); if (buff & 0x40) { write_sram(2, 0x00, "Оки-доки! "); read_sram_to_lsd(2); if (is_good_melody) play_melody (5); else delay(65535); } else { write_sram(2, 0x00, "Фигня какая-то... "); read_sram_to_lsd(2); if (is_bad_melody) play_melody (6); else delay(65535); } write_sram(2, 0x00, "Введите пароль: "); read_sram_to_lsd(2); goto_x(0x40); init_uart(); } return 0; }