no-OS
pcf85263.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef __PCF85263_H__
35 #define __PCF85263_H__
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 #include <stdint.h>
41 #include <string.h>
42 #include "no_os_util.h"
43 #include "no_os_i2c.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 
49 #define PCF85263_REG_100TH_SECONDS 0x00
50 #define PCF85263_REG_SECONDS 0x01
51 #define PCF85263_REG_MINUTES 0x02
52 #define PCF85263_REG_HOURS 0x03
53 #define PCF85263_REG_DAYS 0x04
54 #define PCF85263_REG_WEEKDAYS 0x05
55 #define PCF85263_REG_MONTHS 0x06
56 #define PCF85263_REG_YEARS 0x07
57 #define PCF85263_REG_SECOND_ALARM1 0x08
58 #define PCF85263_REG_MINUTE_ALARM1 0x09
59 #define PCF85263_REG_HOUR_ALARM1 0x0A
60 #define PCF85263_REG_DAY_ALARM1 0x0B
61 #define PCF85263_REG_MONTH_ALARM1 0x0C
62 #define PCF85263_REG_MINUTE_ALARM2 0x0D
63 #define PCF85263_REG_HOUR_ALARM2 0x0E
64 #define PCF85263_REG_WEEKDAY_ALARM2 0x0F
65 #define PCF85263_REG_ALARM_ENABLES 0x10
66 #define PCF85263_REG_TSR1_SECONDS 0x11
67 #define PCF85263_REG_TSR1_MINUTES 0x12
68 #define PCF85263_REG_TSR1_HOURS 0x13
69 #define PCF85263_REG_TSR1_DAYS 0x14
70 #define PCF85263_REG_TSR1_MONTHS 0x15
71 #define PCF85263_REG_TSR1_YEARS 0x16
72 #define PCF85263_REG_TSR2_SECONDS 0x17
73 #define PCF85263_REG_TSR2_MINUTES 0x18
74 #define PCF85263_REG_TSR2_HOURS 0x19
75 #define PCF85263_REG_TSR2_DAYS 0x1A
76 #define PCF85263_REG_TSR2_MONTHS 0x1B
77 #define PCF85263_REG_TSR2_YEARS 0x1C
78 #define PCF85263_REG_TSR3_SECONDS 0x1D
79 #define PCF85263_REG_TSR3_MINUTES 0x1E
80 #define PCF85263_REG_TSR3_HOURS 0x1F
81 #define PCF85263_REG_TSR3_DAYS 0x20
82 #define PCF85263_REG_TSR3_MONTHS 0x21
83 #define PCF85263_REG_TSR3_YEARS 0x22
84 #define PCF85263_REG_TSR_MODE 0x23
85 #define PCF85263_REG_OFFSET 0x24
86 #define PCF85263_REG_OSCILLATOR 0x25
87 #define PCF85263_REG_BATTERY_SWITCH 0x26
88 #define PCF85263_REG_PIN_IO 0x27
89 #define PCF85263_REG_FUNCTION 0x28
90 #define PCF85263_REG_INTA_ENABLE 0x29
91 #define PCF85263_REG_INTB_ENABLE 0x2A
92 #define PCF85263_REG_FLAGS 0x2B
93 #define PCF85263_REG_RAM_BYTE 0x2C
94 #define PCF85263_REG_WATCH_DOG 0x2D
95 #define PCF85263_REG_STOP_ENABLE 0x2E
96 #define PCF85263_REG_RESETS 0x2F
97 
98 #define PCF85263_CPR 0xA4
99 #define PCF85263_BATTERY_SW_MSK NO_OS_BIT(4)
100 
101 /******************************************************************************/
102 /*************************** Types Declarations *******************************/
103 /******************************************************************************/
104 
110  uint8_t sec;
111  uint8_t min;
112  uint8_t hr;
113  uint8_t day;
114  uint8_t mon;
115  uint8_t year;
116 };
117 
125  uint8_t battery_en;
126 };
127 
132 struct pcf85263_dev {
135  uint8_t battery_en;
136 };
137 
138 /******************************************************************************/
139 /************************ Functions Declarations ******************************/
140 /******************************************************************************/
141 
142 /* Read device register. */
143 int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr,
144  uint8_t *reg_data);
145 
146 /* Write device register. */
147 int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr,
148  uint8_t reg_data);
149 
150 /* Update specific register bits. */
151 int pcf85263_update_bits(struct pcf85263_dev *dev, uint8_t reg_addr,
152  uint8_t mask, uint8_t reg_data);
153 
154 /* Set date */
155 int pcf85263_set_date(struct pcf85263_dev *dev, struct pcf85263_date date);
156 
157 /* Read time stamp */
158 int pcf85263_read_ts(struct pcf85263_dev *dev, struct pcf85263_date *ts);
159 
160 /* Initialize the device. */
161 int pcf85263_init(struct pcf85263_dev **device,
163 
164 /* Remove the device and release resources. */
165 int pcf85263_remove(struct pcf85263_dev *dev);
166 
167 #endif //__PCF85263_H__
PCF85263_REG_MONTHS
#define PCF85263_REG_MONTHS
Definition: pcf85263.h:55
pcf85263_date
Structure holding the date parameters.
Definition: pcf85263.h:109
no_os_alloc.h
PCF85263_REG_BATTERY_SWITCH
#define PCF85263_REG_BATTERY_SWITCH
Definition: pcf85263.h:87
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
PCF85263_CPR
#define PCF85263_CPR
Definition: pcf85263.h:98
PCF85263_REG_SECONDS
#define PCF85263_REG_SECONDS
Definition: pcf85263.h:50
pcf85263_write
int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: pcf85263.c:72
PCF85263_REG_HOURS
#define PCF85263_REG_HOURS
Definition: pcf85263.h:52
pcf85263_date::mon
uint8_t mon
Definition: pcf85263.h:114
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
pcf85263_init_param::battery_en
uint8_t battery_en
Definition: pcf85263.h:125
PCF85263_REG_MINUTES
#define PCF85263_REG_MINUTES
Definition: pcf85263.h:51
no_os_delay.h
Header file of Delay functions.
pcf85263_dev::battery_en
uint8_t battery_en
Definition: pcf85263.h:135
PCF85263_BATTERY_SW_MSK
#define PCF85263_BATTERY_SW_MSK
Definition: pcf85263.h:99
pcf85263_date::hr
uint8_t hr
Definition: pcf85263.h:112
PCF85263_REG_YEARS
#define PCF85263_REG_YEARS
Definition: pcf85263.h:56
device
Definition: ad9361_util.h:69
pcf85263_read
int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: pcf85263.c:54
pcf85263_remove
int pcf85263_remove(struct pcf85263_dev *dev)
Remove the device and release resources.
Definition: pcf85263.c:251
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
pcf85263_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: pcf85263.h:134
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
pcf85263_date::day
uint8_t day
Definition: pcf85263.h:113
PCF85263_REG_DAYS
#define PCF85263_REG_DAYS
Definition: pcf85263.h:53
pcf85263_dev
PCF85263 Device structure.
Definition: pcf85263.h:132
pcf85263_init
int pcf85263_init(struct pcf85263_dev **device, struct pcf85263_init_param init_param)
Initialize the device.
Definition: pcf85263.c:113
pcf85263_set_date
int pcf85263_set_date(struct pcf85263_dev *dev, struct pcf85263_date date)
Set date.
Definition: pcf85263.c:154
pcf85263_remove
int pcf85263_remove(struct pcf85263_dev *dev)
Remove the device and release resources.
Definition: pcf85263.c:251
pcf85263.h
Header file of pcf85263 Driver.
pcf85263_read_ts
int pcf85263_read_ts(struct pcf85263_dev *dev, struct pcf85263_date *ts)
Read time stamp.
Definition: pcf85263.c:203
pcf85263_update_bits
int pcf85263_update_bits(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
Update specific register bits.
Definition: pcf85263.c:90
pcf85263_date::sec
uint8_t sec
Definition: pcf85263.h:110
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
pcf85263_init_param::i2c_init
struct no_os_i2c_init_param * i2c_init
Definition: pcf85263.h:124
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
no_os_i2c.h
Header file of I2C Interface.
pcf85263_date::year
uint8_t year
Definition: pcf85263.h:115
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
PCF85263_REG_STOP_ENABLE
#define PCF85263_REG_STOP_ENABLE
Definition: pcf85263.h:95
no_os_bcd2bin
#define no_os_bcd2bin(x)
Definition: no_os_util.h:123
PCF85263_REG_RESETS
#define PCF85263_REG_RESETS
Definition: pcf85263.h:96
pcf85263_write
int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: pcf85263.c:72
pcf85263_read
int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: pcf85263.c:54
PCF85263_REG_100TH_SECONDS
#define PCF85263_REG_100TH_SECONDS
Definition: pcf85263.h:49
pcf85263_init
int pcf85263_init(struct pcf85263_dev **device, struct pcf85263_init_param init_param)
Initialize the device.
Definition: pcf85263.c:113
no_os_util.h
Header file of utility functions.
pcf85263_set_date
int pcf85263_set_date(struct pcf85263_dev *dev, struct pcf85263_date date)
Set date.
Definition: pcf85263.c:154
pcf85263_read_ts
int pcf85263_read_ts(struct pcf85263_dev *dev, struct pcf85263_date *ts)
Read time stamp.
Definition: pcf85263.c:203
pcf85263_update_bits
int pcf85263_update_bits(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
Update specific register bits.
Definition: pcf85263.c:90
pcf85263_init_param
PCF85263 Device initialization parameters.
Definition: pcf85263.h:122
pcf85263_date::min
uint8_t min
Definition: pcf85263.h:111
errno.h
Error macro definition for ARM Compiler.
no_os_bin2bcd
#define no_os_bin2bcd(x)
Definition: no_os_util.h:124