no-OS
pcf85263.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef __PCF85263_H__
41 #define __PCF85263_H__
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 #include <stdint.h>
47 #include <string.h>
48 #include "no_os_util.h"
49 #include "no_os_i2c.h"
50 
51 /******************************************************************************/
52 /********************** Macros and Constants Definitions **********************/
53 /******************************************************************************/
54 
55 #define PCF85263_REG_100TH_SECONDS 0x00
56 #define PCF85263_REG_SECONDS 0x01
57 #define PCF85263_REG_MINUTES 0x02
58 #define PCF85263_REG_HOURS 0x03
59 #define PCF85263_REG_DAYS 0x04
60 #define PCF85263_REG_WEEKDAYS 0x05
61 #define PCF85263_REG_MONTHS 0x06
62 #define PCF85263_REG_YEARS 0x07
63 #define PCF85263_REG_SECOND_ALARM1 0x08
64 #define PCF85263_REG_MINUTE_ALARM1 0x09
65 #define PCF85263_REG_HOUR_ALARM1 0x0A
66 #define PCF85263_REG_DAY_ALARM1 0x0B
67 #define PCF85263_REG_MONTH_ALARM1 0x0C
68 #define PCF85263_REG_MINUTE_ALARM2 0x0D
69 #define PCF85263_REG_HOUR_ALARM2 0x0E
70 #define PCF85263_REG_WEEKDAY_ALARM2 0x0F
71 #define PCF85263_REG_ALARM_ENABLES 0x10
72 #define PCF85263_REG_TSR1_SECONDS 0x11
73 #define PCF85263_REG_TSR1_MINUTES 0x12
74 #define PCF85263_REG_TSR1_HOURS 0x13
75 #define PCF85263_REG_TSR1_DAYS 0x14
76 #define PCF85263_REG_TSR1_MONTHS 0x15
77 #define PCF85263_REG_TSR1_YEARS 0x16
78 #define PCF85263_REG_TSR2_SECONDS 0x17
79 #define PCF85263_REG_TSR2_MINUTES 0x18
80 #define PCF85263_REG_TSR2_HOURS 0x19
81 #define PCF85263_REG_TSR2_DAYS 0x1A
82 #define PCF85263_REG_TSR2_MONTHS 0x1B
83 #define PCF85263_REG_TSR2_YEARS 0x1C
84 #define PCF85263_REG_TSR3_SECONDS 0x1D
85 #define PCF85263_REG_TSR3_MINUTES 0x1E
86 #define PCF85263_REG_TSR3_HOURS 0x1F
87 #define PCF85263_REG_TSR3_DAYS 0x20
88 #define PCF85263_REG_TSR3_MONTHS 0x21
89 #define PCF85263_REG_TSR3_YEARS 0x22
90 #define PCF85263_REG_TSR_MODE 0x23
91 #define PCF85263_REG_OFFSET 0x24
92 #define PCF85263_REG_OSCILLATOR 0x25
93 #define PCF85263_REG_BATTERY_SWITCH 0x26
94 #define PCF85263_REG_PIN_IO 0x27
95 #define PCF85263_REG_FUNCTION 0x28
96 #define PCF85263_REG_INTA_ENABLE 0x29
97 #define PCF85263_REG_INTB_ENABLE 0x2A
98 #define PCF85263_REG_FLAGS 0x2B
99 #define PCF85263_REG_RAM_BYTE 0x2C
100 #define PCF85263_REG_WATCH_DOG 0x2D
101 #define PCF85263_REG_STOP_ENABLE 0x2E
102 #define PCF85263_REG_RESETS 0x2F
103 
104 #define PCF85263_CPR 0xA4
105 #define PCF85263_BATTERY_SW_MSK NO_OS_BIT(4)
106 
107 /******************************************************************************/
108 /*************************** Types Declarations *******************************/
109 /******************************************************************************/
110 
116  uint8_t sec;
117  uint8_t min;
118  uint8_t hr;
119  uint8_t day;
120  uint8_t mon;
121  uint8_t year;
122 };
123 
131  uint8_t battery_en;
132 };
133 
138 struct pcf85263_dev {
141  uint8_t battery_en;
142 };
143 
144 /******************************************************************************/
145 /************************ Functions Declarations ******************************/
146 /******************************************************************************/
147 
148 /* Read device register. */
149 int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr,
150  uint8_t *reg_data);
151 
152 /* Write device register. */
153 int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr,
154  uint8_t reg_data);
155 
156 /* Update specific register bits. */
157 int pcf85263_update_bits(struct pcf85263_dev *dev, uint8_t reg_addr,
158  uint8_t mask, uint8_t reg_data);
159 
160 /* Set date */
161 int pcf85263_set_date(struct pcf85263_dev *dev, struct pcf85263_date date);
162 
163 /* Read time stamp */
164 int pcf85263_read_ts(struct pcf85263_dev *dev, struct pcf85263_date *ts);
165 
166 /* Initialize the device. */
167 int pcf85263_init(struct pcf85263_dev **device,
169 
170 /* Remove the device and release resources. */
171 int pcf85263_remove(struct pcf85263_dev *dev);
172 
173 #endif //__PCF85263_H__
PCF85263_REG_MONTHS
#define PCF85263_REG_MONTHS
Definition: pcf85263.h:61
pcf85263_date
Structure holding the date parameters.
Definition: pcf85263.h:115
no_os_alloc.h
PCF85263_REG_BATTERY_SWITCH
#define PCF85263_REG_BATTERY_SWITCH
Definition: pcf85263.h:93
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:165
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:58
PCF85263_CPR
#define PCF85263_CPR
Definition: pcf85263.h:104
PCF85263_REG_SECONDS
#define PCF85263_REG_SECONDS
Definition: pcf85263.h:56
pcf85263_write
int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: pcf85263.c:78
PCF85263_REG_HOURS
#define PCF85263_REG_HOURS
Definition: pcf85263.h:58
pcf85263_date::mon
uint8_t mon
Definition: pcf85263.h:120
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:119
pcf85263_init_param::battery_en
uint8_t battery_en
Definition: pcf85263.h:131
PCF85263_REG_MINUTES
#define PCF85263_REG_MINUTES
Definition: pcf85263.h:57
no_os_delay.h
Header file of Delay functions.
pcf85263_dev::battery_en
uint8_t battery_en
Definition: pcf85263.h:141
hmc630x_init_param::data
struct no_os_gpio_init_param data
Definition: hmc630x.h:305
PCF85263_BATTERY_SW_MSK
#define PCF85263_BATTERY_SW_MSK
Definition: pcf85263.h:105
pcf85263_date::hr
uint8_t hr
Definition: pcf85263.h:118
PCF85263_REG_YEARS
#define PCF85263_REG_YEARS
Definition: pcf85263.h:62
device
Definition: ad9361_util.h:75
pcf85263_read
int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: pcf85263.c:60
pcf85263_remove
int pcf85263_remove(struct pcf85263_dev *dev)
Remove the device and release resources.
Definition: pcf85263.c:257
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:60
pcf85263_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: pcf85263.h:140
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:119
PCF85263_REG_DAYS
#define PCF85263_REG_DAYS
Definition: pcf85263.h:59
pcf85263_dev
PCF85263 Device structure.
Definition: pcf85263.h:138
pcf85263_init
int pcf85263_init(struct pcf85263_dev **device, struct pcf85263_init_param init_param)
Initialize the device.
Definition: pcf85263.c:119
pcf85263_set_date
int pcf85263_set_date(struct pcf85263_dev *dev, struct pcf85263_date date)
Set date.
Definition: pcf85263.c:160
pcf85263_remove
int pcf85263_remove(struct pcf85263_dev *dev)
Remove the device and release resources.
Definition: pcf85263.c:257
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:209
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:96
pcf85263_date::sec
uint8_t sec
Definition: pcf85263.h:116
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:107
pcf85263_init_param::i2c_init
struct no_os_i2c_init_param * i2c_init
Definition: pcf85263.h:130
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:196
no_os_i2c.h
Header file of I2C Interface.
pcf85263_date::year
uint8_t year
Definition: pcf85263.h:121
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:75
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:70
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
PCF85263_REG_STOP_ENABLE
#define PCF85263_REG_STOP_ENABLE
Definition: pcf85263.h:101
no_os_bcd2bin
#define no_os_bcd2bin(x)
Definition: no_os_util.h:129
PCF85263_REG_RESETS
#define PCF85263_REG_RESETS
Definition: pcf85263.h:102
pcf85263_write
int pcf85263_write(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Write device register.
Definition: pcf85263.c:78
pcf85263_read
int pcf85263_read(struct pcf85263_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Read device register.
Definition: pcf85263.c:60
PCF85263_REG_100TH_SECONDS
#define PCF85263_REG_100TH_SECONDS
Definition: pcf85263.h:55
pcf85263_init
int pcf85263_init(struct pcf85263_dev **device, struct pcf85263_init_param init_param)
Initialize the device.
Definition: pcf85263.c:119
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:160
pcf85263_read_ts
int pcf85263_read_ts(struct pcf85263_dev *dev, struct pcf85263_date *ts)
Read time stamp.
Definition: pcf85263.c:209
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:96
pcf85263_init_param
PCF85263 Device initialization parameters.
Definition: pcf85263.h:128
pcf85263_date::min
uint8_t min
Definition: pcf85263.h:117
errno.h
Error macro definition for ARM Compiler.
no_os_bin2bcd
#define no_os_bin2bcd(x)
Definition: no_os_util.h:130