int get_cursor_pos() { byte_out(SCREEN_CTRL, CLR_HIGH); int offset = byte_in(SCREEN_DATA) << 8; byte_out(SCREEN_CTRL, CLR_LOW); offset += byte_in(SCREEN_DATA); return offset; }
int getlnmaxsep (buffer_ref b, char *d, unsigned int max, unsigned int *w, char const *sep, unsigned int seplen) { register int ok = 1 ; if (max < *w) return (errno = EINVAL, -1) ; for (;;) { unsigned int len = (*w + buffer_len(b) > max) ? max - *w : buffer_len(b) ; unsigned int pos = byte_in(buffer_PEEK(b), len, sep, seplen) ; byte_copy(d + *w, pos, buffer_PEEK(b)) ; *w += pos ; buffer_SEEK(b, pos) ; if (*w >= max) return (errno = ERANGE, -1) ; if (pos < len) { d[(*w)++] = *buffer_PEEK(b) ; buffer_SEEK(b, 1) ; return ok ; } { register int r = buffer_fill(b) ; if (r <= 0) return r ; } ok = 2 ; } }
void eeprom_ByteRead(uint16_t address, uint8_t *data) { ACK_Poll(); // Begin ACK polling bstart(); // Generate Start condition byte_out(eeprom_control); // Output control byte byte_out((uint8_t)(address>>8));// Output address MSB byte_out((uint8_t)address); // Output address LSB bstart(); // Generate Start condition byte_out(eeprom_control | 0x01);// Output control byte *data = byte_in(NAKBIT); // Input data byte bstop(); // Generate Stop condition }
unsigned int siovec_bytein (siovec_t const *v, unsigned int n, char const *sep, unsigned int seplen) { unsigned int w = 0 ; unsigned int i = 0 ; for (; i < n ; i++) { register unsigned int pos = byte_in(v[i].s, v[i].len, sep, seplen) ; w += pos ; if (pos < v[i].len) break ; } return w ; }
void eeprom_SequentialRead(uint16_t address, uint8_t *data, uint16_t numbytes) { uint16_t i; // Loop counter ACK_Poll(); // Begin ACK polling bstart(); // Generate Start condition byte_out(eeprom_control); // Output control byte byte_out((uint8_t)(address>>8));// Output address MSB byte_out((uint8_t)address); // Output address LSB bstart(); // Generate Start condition byte_out(eeprom_control | 0x01);// Output control byte for (i = 0; i < numbytes; i++) // Loop through data bytes { if (i < (numbytes - 1)) // Check if more data will be read { data[i] = byte_in(ACKBIT); // If not last, input byte & send ACK } else { data[i] = byte_in(NAKBIT); // If last byte, input byte & send NAK } } bstop(); // Generate Stop condition }