Junyi Zhao | c085850 | 2024-01-17 10:59:34 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef __FD650H__ |
| 8 | #define __FD650H__ |
| 9 | |
| 10 | #include "common.h" |
| 11 | #include "uart.h" |
| 12 | #include "FreeRTOS.h" |
| 13 | |
| 14 | #define FD650_BIT_ENABLE 0x01 |
| 15 | #define FD650_BIT_SLEEP 0x04 |
| 16 | //#define FD650_BIT_7SEG 0x08 |
| 17 | #define FD650_BIT_INTENS1 0x10 |
| 18 | #define FD650_BIT_INTENS2 0x20 |
| 19 | #define FD650_BIT_INTENS3 0x30 |
| 20 | #define FD650_BIT_INTENS4 0x40 |
| 21 | #define FD650_BIT_INTENS5 0x50 |
| 22 | #define FD650_BIT_INTENS6 0x60 |
| 23 | #define FD650_BIT_INTENS7 0x70 |
| 24 | #define FD650_BIT_INTENS8 0x00 |
| 25 | |
| 26 | #define FD650_SYSOFF 0x0400 |
| 27 | #define FD650_SYSON (FD650_SYSOFF | FD650_BIT_ENABLE) |
| 28 | #define FD650_SLEEPOFF FD650_SYSOFF |
| 29 | #define FD650_SLEEPON (FD650_SYSOFF | FD650_BIT_SLEEP) |
| 30 | //#define FD650_7SEG_ON (FD650_SYSON | FD650_BIT_7SEG) |
| 31 | #define FD650_8SEG_ON (FD650_SYSON | 0x00) |
| 32 | #define FD650_SYSON_1 (FD650_SYSON | FD650_BIT_INTENS1) |
| 33 | #define FD650_SYSON_4 (FD650_SYSON | FD650_BIT_INTENS4) |
| 34 | #define FD650_SYSON_8 (FD650_SYSON | FD650_BIT_INTENS8) |
| 35 | |
| 36 | |
| 37 | #define FD650_DIG0 0x1400 |
| 38 | #define FD650_DIG1 0x1500 |
| 39 | #define FD650_DIG2 0x1600 |
| 40 | #define FD650_DIG3 0x1700 |
| 41 | |
| 42 | #define FD650_DOT 0x0080 |
| 43 | |
| 44 | #define FD650_GET_KEY 0x0700 |
| 45 | |
| 46 | struct fd650_bus { |
| 47 | /* |
| 48 | * udelay - delay [us] between GPIO toggle operations, |
| 49 | * which is 1/4 of I2C speed clock period. |
| 50 | */ |
| 51 | int bus_id; |
| 52 | int udelay; |
| 53 | /* sda, scl */ |
| 54 | uint32_t sda; |
| 55 | uint32_t scl; |
| 56 | }; |
| 57 | |
| 58 | enum FD650State { |
| 59 | FD650_STATE_DEFAULT = 0, |
| 60 | FD650_STATE_SHOW, |
| 61 | FD650_STATE_TIME, |
| 62 | FD650_STATE_INVALID, |
| 63 | }; |
| 64 | |
| 65 | uint8_t fd650_read(struct fd650_bus *bus); |
| 66 | void fd650_write(struct fd650_bus *bus, uint32_t cmd); |
| 67 | int fd650_bus_init(uint32_t id); |
| 68 | void led_show_650(char *str, unsigned char sec_flag, unsigned char lock); |
| 69 | |
| 70 | #endif |