Francesco Salvatore | 6c17a23 | 2018-12-11 17:30:22 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2018 Fairphone B.V. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef _TARGET_FP2_RGB_LED_H_ |
| 16 | #define _TARGET_FP2_RGB_LED_H_ |
| 17 | |
| 18 | #include <pm8x41.h> |
| 19 | |
| 20 | // Slave-ID |
| 21 | #define SLAVE_ID 0x10000 |
| 22 | |
| 23 | // RGB module registers |
| 24 | #define RGB_DRIVER_BASE_ADDR 0xD000 |
| 25 | #define RGB_DRIVER_LED_SRC_SEL 0x45 |
| 26 | #define RGB_DRIVER_EN_CTL 0x46 |
| 27 | #define RGB_LED_VALUE_RED 0x80 |
| 28 | #define RGB_LED_VALUE_GREEN 0x40 |
| 29 | #define RGB_LED_VALUE_BLUE 0x20 |
| 30 | |
| 31 | // LPG module registers |
| 32 | #define LPG_DRIVER_BASE_ADDR 0xB000 |
| 33 | #define LPG_DRIVER_LED_RED 0x700 |
| 34 | #define LPG_DRIVER_LED_GREEN 0x600 |
| 35 | #define LPG_DRIVER_LED_BLUE 0x500 |
| 36 | #define LPG_PATTERN_CONFIG 0x40 |
| 37 | #define LPG_PWM_SIZE_CLK 0x41 |
| 38 | #define LPG_PWM_FREQ_PREDIV 0x42 |
| 39 | #define LPG_PWM_TYPE_CONFIG 0x43 |
| 40 | #define LPG_VALUE_LSB 0x44 |
| 41 | #define LPG_VALUE_MSB 0x45 |
| 42 | #define LPG_ENABLE_CONTROL 0x46 |
| 43 | |
| 44 | typedef enum rgb_led_return_code |
| 45 | { |
| 46 | RGB_LED_SUCCESS, |
| 47 | RGB_LED_GENERIC_ERROR, |
| 48 | RGB_LED_INVALID_PARAMETER |
| 49 | } rgb_led_return_code; |
| 50 | |
| 51 | typedef enum rgb_led_brightness |
| 52 | { |
| 53 | RGB_LED_BRIGHTNESS_LOW = 0x80, |
| 54 | RGB_LED_BRIGHTNESS_MID = 0x7F, |
| 55 | RGB_LED_BRIGHTNESS_HIG = 0xFF |
| 56 | } rgb_led_brightness; |
| 57 | |
| 58 | rgb_led_return_code led_init(void); |
| 59 | rgb_led_return_code led_enable(uint8_t led, rgb_led_brightness brightness); |
| 60 | rgb_led_return_code led_blink_enable(uint8_t led, uint8_t pwm_freq, uint8_t duty_cycle); |
| 61 | rgb_led_return_code led_disable(uint8_t led); |
| 62 | |
| 63 | rgb_led_return_code led_deinit(void); |
| 64 | |
| 65 | #endif //_TARGET_FP2_RGB_LED_H_ |