This library creates the interface to operate the TLC5940. This device manages 16 PWM outputs.
tlc5940.h@3:40cb2f9adc4d, 2010-11-27 (annotated)
- Committer:
- Fiuba
- Date:
- Sat Nov 27 01:08:28 2010 +0000
- Revision:
- 3:40cb2f9adc4d
- Parent:
- 2:500ec33cd4b6
I think the documentation is now fully functional :)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Fiuba | 1:e8c8347fa919 | 1 | /* |
Fiuba | 1:e8c8347fa919 | 2 | * tlc5940 - Interface to operate TI's IC TLC5940 |
Fiuba | 1:e8c8347fa919 | 3 | * Copyright (C) 2010 German Bassi. |
Fiuba | 1:e8c8347fa919 | 4 | * |
Fiuba | 1:e8c8347fa919 | 5 | * This program is free software; you can redistribute it and/or modify |
Fiuba | 1:e8c8347fa919 | 6 | * it under the terms of the GNU General Public License as published by |
Fiuba | 1:e8c8347fa919 | 7 | * the Free Software Foundation; either version 2 of the License, or |
Fiuba | 1:e8c8347fa919 | 8 | * (at your option) any later version. |
Fiuba | 1:e8c8347fa919 | 9 | * |
Fiuba | 1:e8c8347fa919 | 10 | * This program is distributed in the hope that it will be useful, |
Fiuba | 1:e8c8347fa919 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
Fiuba | 1:e8c8347fa919 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Fiuba | 1:e8c8347fa919 | 13 | * GNU General Public License for more details. |
Fiuba | 1:e8c8347fa919 | 14 | * |
Fiuba | 1:e8c8347fa919 | 15 | * You should have received a copy of the GNU General Public License |
Fiuba | 1:e8c8347fa919 | 16 | * along with this program; if not, write to the Free Software |
Fiuba | 1:e8c8347fa919 | 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Fiuba | 1:e8c8347fa919 | 18 | */ |
Fiuba | 1:e8c8347fa919 | 19 | |
Fiuba | 0:64ea4d75027c | 20 | #ifndef MBED_TLC5940_H |
Fiuba | 0:64ea4d75027c | 21 | #define MBED_TLC5940_H |
Fiuba | 0:64ea4d75027c | 22 | |
Fiuba | 0:64ea4d75027c | 23 | #include "mbed.h" |
Fiuba | 0:64ea4d75027c | 24 | |
Fiuba | 3:40cb2f9adc4d | 25 | /** TI's TLC5940 interface class |
Fiuba | 3:40cb2f9adc4d | 26 | * |
Fiuba | 3:40cb2f9adc4d | 27 | * Example: |
Fiuba | 3:40cb2f9adc4d | 28 | * @code |
Fiuba | 3:40cb2f9adc4d | 29 | * // Turn on all the outputs |
Fiuba | 3:40cb2f9adc4d | 30 | * # include "mbed.h" |
Fiuba | 3:40cb2f9adc4d | 31 | * # include "tlc5940.h" |
Fiuba | 3:40cb2f9adc4d | 32 | * |
Fiuba | 3:40cb2f9adc4d | 33 | * int main() { |
Fiuba | 3:40cb2f9adc4d | 34 | * int DC_data[2*96]; |
Fiuba | 3:40cb2f9adc4d | 35 | * int GS_data[2*16]; |
Fiuba | 3:40cb2f9adc4d | 36 | * |
Fiuba | 3:40cb2f9adc4d | 37 | * // Dot Correction Values |
Fiuba | 3:40cb2f9adc4d | 38 | * for (int i=0; i<2*96; i++) DC_data[i] = 1; |
Fiuba | 3:40cb2f9adc4d | 39 | * // Grayscale Values |
Fiuba | 3:40cb2f9adc4d | 40 | * for (int i=0; i<2*16; i++) GS_data[i] = 0xFF; |
Fiuba | 3:40cb2f9adc4d | 41 | * |
Fiuba | 3:40cb2f9adc4d | 42 | * // Create object |
Fiuba | 3:40cb2f9adc4d | 43 | * tlc5940 tlc_driver(2, DC_data); |
Fiuba | 3:40cb2f9adc4d | 44 | * // Send data |
Fiuba | 3:40cb2f9adc4d | 45 | * tlc_driver.send_data(GS_data); |
Fiuba | 3:40cb2f9adc4d | 46 | * |
Fiuba | 3:40cb2f9adc4d | 47 | * while (1) {} |
Fiuba | 3:40cb2f9adc4d | 48 | * } |
Fiuba | 3:40cb2f9adc4d | 49 | * @endcode |
Fiuba | 3:40cb2f9adc4d | 50 | */ |
Fiuba | 0:64ea4d75027c | 51 | class tlc5940 { |
Fiuba | 0:64ea4d75027c | 52 | private: |
Fiuba | 0:64ea4d75027c | 53 | bool first_cycle_flag; |
Fiuba | 0:64ea4d75027c | 54 | int GSCLK_counter, data_counter; |
Fiuba | 0:64ea4d75027c | 55 | int aux_value, aux_ind; |
Fiuba | 2:500ec33cd4b6 | 56 | int num_ic; |
Fiuba | 0:64ea4d75027c | 57 | |
Fiuba | 0:64ea4d75027c | 58 | DigitalOut VPROG; |
Fiuba | 0:64ea4d75027c | 59 | DigitalOut SIN; |
Fiuba | 0:64ea4d75027c | 60 | DigitalOut SCLK; |
Fiuba | 0:64ea4d75027c | 61 | DigitalOut XLAT; |
Fiuba | 0:64ea4d75027c | 62 | DigitalOut BLANK; |
Fiuba | 0:64ea4d75027c | 63 | DigitalOut DCPROG; |
Fiuba | 0:64ea4d75027c | 64 | DigitalOut GSCLK; |
Fiuba | 0:64ea4d75027c | 65 | |
Fiuba | 0:64ea4d75027c | 66 | DigitalIn SOUT; |
Fiuba | 0:64ea4d75027c | 67 | DigitalIn XERR; |
Fiuba | 0:64ea4d75027c | 68 | |
Fiuba | 0:64ea4d75027c | 69 | public: |
Fiuba | 1:e8c8347fa919 | 70 | /** Create a tlc5940 interface object connected to some specifics pins |
Fiuba | 1:e8c8347fa919 | 71 | * |
Fiuba | 2:500ec33cd4b6 | 72 | * @param num_ics Number of TLC5940 connected in series |
Fiuba | 1:e8c8347fa919 | 73 | * @param DC_data[] Dot Correction values for initialization |
Fiuba | 1:e8c8347fa919 | 74 | */ |
Fiuba | 2:500ec33cd4b6 | 75 | tlc5940 (int num_ics, int DC_data[]); |
Fiuba | 1:e8c8347fa919 | 76 | |
Fiuba | 1:e8c8347fa919 | 77 | /** Send the specified set of grayscale values |
Fiuba | 1:e8c8347fa919 | 78 | * |
Fiuba | 1:e8c8347fa919 | 79 | * @param data[] Array of 12-bit Grayscale values for transmission |
Fiuba | 1:e8c8347fa919 | 80 | */ |
Fiuba | 0:64ea4d75027c | 81 | void send_data (int data[]); |
Fiuba | 0:64ea4d75027c | 82 | }; |
Fiuba | 0:64ea4d75027c | 83 | |
Fiuba | 0:64ea4d75027c | 84 | #endif |