1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #ifndef __DS1302DRV_H__
- #define __DS1302DRV_H__
-
-
- #include "stm32f7xx_hal.h"
-
- #include "stm32f7xx_hal.h"
-
-
- #define DEF_true 1
- #define DEF_false 0
-
-
- #define kRamSize 31
-
- #define DS1302_SCLK_GPIO_Port GPIOB
- #define DS1302_SCLK_Pin GPIO_PIN_9
- //DS1302_CE_GPIO_Port, DS1302_CE_Pin
- #define DS1302_CE_GPIO_Port GPIOE
- #define DS1302_CE_Pin GPIO_PIN_1
- //DS1302_IO_GPIO_Port, DS1302_IO_Pin
- #define DS1302_IO_GPIO_Port GPIOE
- #define DS1302_IO_Pin GPIO_PIN_0
- typedef enum
- {
- kSecondReg = 0,
- kMinuteReg = 1,
- kHourReg = 2,
- kDateReg = 3,
- kMonthReg = 4,
- kDayReg = 5,
- kYearReg = 6,
- kWriteProtectReg = 7,
- kChargeReg = 8,
-
- // The RAM register space follows the clock register space.
- kRamAddress0 = 32
- } DS1302_Register;
-
- typedef enum
- {
- kClockBurstRead = 0xBF,
- kClockBurstWrite = 0xBE,
- kRamBurstRead = 0xFF,
- kRamBurstWrite = 0xFE
- } DS1302_Command;
-
- typedef enum
- {
- kSunday = 1,
- kMonday = 2,
- kTuesday = 3,
- kWednesday = 4,
- kThursday = 5,
- kFriday = 6,
- kSaturday = 7
- } DS1302_Day;
-
-
-
-
- extern uint8_t time_buf_reg[8];
-
-
-
- uint8_t bcdToDec(const uint8_t bcd) ;
- uint8_t decToBcd(const uint8_t dec) ;
- uint8_t hourFromRegisterValue(const uint8_t value);
- void DS1302_writeOut(const uint8_t value, uint8_t readAfter) ;
- uint8_t DS1302_readIn(void) ;
- uint8_t DS1302_readRegister(const uint8_t reg) ;
- void DS1302_writeRegister(const uint8_t reg, const uint8_t value) ;
- void DS1302_writeProtect(const uint8_t enable) ;
- void DS1302_halt(const uint8_t enable) ;
- void DS1302_writeRam(const uint8_t address, const uint8_t value) ;
- uint8_t DS1302_readRam(const uint8_t address) ;
- void DS1302_writeRamBulk(const uint8_t* const data, int len) ;
- void DS1302_readRamBulk(uint8_t* const data, int len) ;
-
- //Top layer function
- void DS1302_timeRead(void) ;
- void DS1302_timeWrite(void) ;
-
-
- #endif /* __DS1302DRV_H__ */
|