void testmem(char *unused) { char *buf; uint16_t size; DS_P( PSTR("testing ") ); size = 32765; display_udec(size, 5,' '); DS_P( PSTR(" bytes of RAM - ") ); buf = malloc( size ); if (buf != NULL) { // write memset( buf, 0x77, size ); for (uint16_t i = 0; i<size; i++) *(buf+i) = (i & 0xff); // read for (uint16_t i = 0; i<size; i++) { if (*(buf+i) != (i & 0xff)) { DS_P( PSTR("Problmes at ") ); display_udec(i, 5,' '); DNL(); free( buf ); return; } } free( buf ); DS_P( PSTR("OK") ); } else { DS_P( PSTR("Alloc failed") ); } DNL(); }
void ntp_func(char *in) { uint8_t hb[6], t; if(in == 0 || in[1] == 0) { t = 1, hb[0] = 7; } else { t = fromhex(in+1, hb, 6); } if(t == 1) { t = hb[0]; ntp_get(hb); if(t&1) { DH2(hb[0]); DC('-'); DH2(hb[1]); DC('-'); DH2(hb[2]); } if((t&3) == 3) DC(' '); if(t&2) { DH2(hb[3]); DC(':'); DH2(hb[4]); DC(':'); DH2(hb[5]); } if(t&4) { DC('.'); display_udec((uint16_t)(ntp_hsec*100)/125, 2, '0'); } DNL(); } else if(t == 6) { tm_t t; t.tm_year = bcd2dec(hb[0]); t.tm_mon = bcd2dec(hb[1]); t.tm_mday = bcd2dec(hb[2]); t.tm_hour = bcd2dec(hb[3]); t.tm_min = bcd2dec(hb[4]); t.tm_sec = bcd2dec(hb[5]); ntp_sec = ntp_tm2sec(&t); } }