void ds3234_write(uint8_t addr, uint8_t data) { gpio_clear(RTCCS_PORT, RTCCS_PIN); clock_out(addr | 0x80); clock_out(data); gpio_set(RTCCS_PORT, RTCCS_PIN); }
// Clock Test Process void ClockTest(clock *clock) { struct msgenv* env = (struct msgenv *) malloc (sizeof (struct msgenv)); env->msg_type = (char*)malloc (sizeof (SIZE)); env->msg_text = (char*)malloc (sizeof (SIZE)); if (env){ //now enter infinite loop while (1) { clock_out(clock, env); usleep(100000); /*get_console_chars(env); //keyboard input env = receive_message(); //***STOPS HERE TO WAIT FOR INPUT while (env == NULL) { usleep(100000); env = receive_message(); } send_console_chars(env); //CRT output, wait for ack env = receive_message(); while (env == NULL) { usleep (100000); env = receive_message(); }*/ } } }
/* Utility to send the preamble, address, and register (common to read and write). */ static void bitbang_pre(struct mii_bus *bus, int read, u8 addr, u8 reg) { int i; /* CFE uses a really long preamble (40 bits). We'll do the same. */ mdio_active(bus); for (i = 0; i < 40; i++) { clock_out(bus, 1); } /* send the start bit (01) and the read opcode (10) or write (10) */ clock_out(bus, 0); clock_out(bus, 1); clock_out(bus, read); clock_out(bus, !read); /* send the PHY address */ for (i = 0; i < 5; i++) { clock_out(bus, (addr & 0x10) != 0); addr <<= 1; } /* send the register address */ for (i = 0; i < 5; i++) { clock_out(bus, (reg & 0x10) != 0); reg <<= 1; } }
uint8_t ds3234_read(uint8_t addr) { uint8_t out; gpio_clear(RTCCS_PORT, RTCCS_PIN); clock_out(addr & 0x7F); out = clock_in(); gpio_set(RTCCS_PORT, RTCCS_PIN); return out; }