Add a get_offset API call to make codec_advance_buffer_loc_callback work.
[Rockbox.git] / firmware / drivers / rtc / rtc_rx5x348ab.c
blob429a221b1a8878e226a3dac4058a7d0a1b0e6fb7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: rtc_as3514.c 12131 2007-01-27 20:48:48Z dan_a $
10 * Copyright (C) 2007 by Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "config.h"
21 #include "spi.h"
22 #include "rtc.h"
23 #include <stdbool.h>
24 /* Choose one of: */
25 #define ADDR_READ 0x04
26 #define ADDR_WRITE 0x00
27 /* and one of: */
28 #define ADDR_ONE 0x08
29 #define ADDR_BURST 0x00
30 void rtc_init(void)
34 int rtc_read_datetime(unsigned char* buf)
36 char command = ADDR_READ|ADDR_BURST; /* burst read from the start of the time/date reg */
37 spi_block_transfer(SPI_target_RX5X348AB,
38 &command, 1, buf, 7);
39 return 1;
41 int rtc_write_datetime(unsigned char* buf)
43 char command = ADDR_WRITE|ADDR_BURST; /* burst read from the start of the time/date reg */
44 char data[8];
45 int i;
46 data[0] = command;
47 for (i=1;i<8;i++)
48 data[i] = buf[i-1];
49 spi_block_transfer(SPI_target_RX5X348AB,
50 data, 8, NULL, 0);
51 return 1;