tinyusb
pca9532.h
1 /*****************************************************************************
2  *
3  * Copyright(C) 2011, Embedded Artists AB
4  * All rights reserved.
5  *
6  ******************************************************************************
7  * Software that is described herein is for illustrative purposes only
8  * which provides customers with programming information regarding the
9  * products. This software is supplied "AS IS" without any warranties.
10  * Embedded Artists AB assumes no responsibility or liability for the
11  * use of the software, conveys no license or title under any patent,
12  * copyright, or mask work right to the product. Embedded Artists AB
13  * reserves the right to make changes in the software without
14  * notification. Embedded Artists AB also make no representation or
15  * warranty that such application will be suitable for the specified
16  * use without further testing or modification.
17  *****************************************************************************/
18 #ifndef __PCA9532C_H
19 #define __PCA9532C_H
20 
21 
22 #define PCA9532_I2C_ADDR (0x60)
23 
24 #define PCA9532_INPUT0 0x00
25 #define PCA9532_INPUT1 0x01
26 #define PCA9532_PSC0 0x02
27 #define PCA9532_PWM0 0x03
28 #define PCA9532_PSC1 0x04
29 #define PCA9532_PWM1 0x05
30 #define PCA9532_LS0 0x06
31 #define PCA9532_LS1 0x07
32 #define PCA9532_LS2 0x08
33 #define PCA9532_LS3 0x09
34 
35 #define PCA9532_AUTO_INC 0x10
36 
37 
38 /*
39  * The Keys on the base board are mapped to LED0 -> LED3 on
40  * the PCA9532.
41  */
42 
43 #define KEY1 0x0001
44 #define KEY2 0x0002
45 #define KEY3 0x0004
46 #define KEY4 0x0008
47 
48 #define KEY_MASK 0x000F
49 
50 /*
51  * MMC Card Detect and MMC Write Protect are mapped to LED4
52  * and LED5 on the PCA9532. Please note that WP is active low.
53  */
54 
55 #define MMC_CD 0x0010
56 #define MMC_WP 0x0020
57 
58 #define MMC_MASK 0x30
59 
60 /* NOTE: LED6 and LED7 on PCA9532 are not connected to anything */
61 #define PCA9532_NOT_USED 0xC0
62 
63 /*
64  * Below are the LED constants to use when enabling/disabling a LED.
65  * The LED names are the names printed on the base board and not
66  * the names from the PCA9532 device. base_LED1 -> LED8 on PCA9532,
67  * base_LED2 -> LED9, and so on.
68  */
69 
70 #define LED1 0x0100
71 #define LED2 0x0200
72 #define LED3 0x0400
73 #define LED4 0x0800
74 #define LED5 0x1000
75 #define LED6 0x2000
76 #define LED7 0x4000
77 #define LED8 0x8000
78 
79 #define LED_MASK 0xFF00
80 
81 void pca9532_init (void);
82 uint16_t pca9532_getLedState (uint32_t shadow);
83 void pca9532_setLeds (uint16_t ledOnMask, uint16_t ledOffMask);
84 void pca9532_setBlink0Period(uint8_t period);
85 void pca9532_setBlink0Duty(uint8_t duty);
86 void pca9532_setBlink0Leds(uint16_t ledMask);
87 void pca9532_setBlink1Period(uint8_t period);
88 void pca9532_setBlink1Duty(uint8_t duty);
89 void pca9532_setBlink1Leds(uint16_t ledMask);
90 
91 #endif /* end __PCA9532C_H */
92 /****************************************************************************
93 ** End Of File
94 *****************************************************************************/