commit 96f25a55970bc770398768ec0df649f6f4e5196b Author: Adrien Van Date: Thu Jan 5 12:32:34 2017 +0100 first commit diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..eb671ac --- /dev/null +++ b/main.cpp @@ -0,0 +1,18 @@ +/* + * ws2801.cpp + * + * Created: 26-12-16 21:56:18 + * Author : Adrien + */ + +#include + + +int main(void) +{ + /* Replace with your application code */ + while (1) + { + } +} + diff --git a/ws2801.componentinfo.xml b/ws2801.componentinfo.xml new file mode 100644 index 0000000..7bcf021 --- /dev/null +++ b/ws2801.componentinfo.xml @@ -0,0 +1,86 @@ + + + + + + + Device + Startup + + + Atmel + 1.1.0 + E:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + E:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.1.130\include + + include + C + + + include + + + + + E:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.1.130\include\avr\iom328p.h + + header + C + UMk4QUzkkuShabuoYtNl/Q== + + include/avr/iom328p.h + + + + + E:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.1.130\templates\main.c + template + source + C Exe + GD1k8YYhulqRs6FD1B2Hog== + + templates/main.c + Main file (.c) + + + + E:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.1.130\templates\main.cpp + template + source + C Exe + NYGn72U290x6jLD4yI/K6g== + + templates/main.cpp + Main file (.cpp) + + + + E:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p + + libraryPrefix + GCC + + + gcc/dev/atmega328p + + + + + ATmega_DFP + E:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.1.130/Atmel.ATmega_DFP.pdsc + 1.1.130 + true + ATmega328P + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/ws2801.cpp b/ws2801.cpp new file mode 100644 index 0000000..5709ee5 --- /dev/null +++ b/ws2801.cpp @@ -0,0 +1,48 @@ +/* + * ws2801.cpp + * + * Created: 26-12-16 21:57:10 + * Author: Adrien + */ + +#include +#include + +/* + L'espace mémoir à envoyer au ci est constituer comme ça : +ciN |-----------0-----------||-----------1-----------||...||-----------N-----------| Ci numéro +coulB |R7...R0|G7...G0|B7...B0||R7...R0|G7...G0|B7...B0||...||R7...R0|G7...G0|B7...B0| Valeur Couleurs bit n +coul |--RED--|-GREEN-|--BLUE-||--RED--|-GREEN-|--BLUE-||...||--RED--|-GREEN-|--BLUE-| Valeur Couleurs +bitN |7.....0|7.....0|7.....0||7.....0|7.....0|7.....0||...||7.....0|7.....0|7.....0| Bit n +t[] |---0---|---1---|---2---||---3---|---4---|---5---||...||-3*N+0-|-3*N+1-|-3*N+3-| Emplacement dans le tableau + +Pour l'envois, il faut commencer par le bit 7 ! + +*/ + + ws2801::ws2801(uint8_t pin_clk, uint8_t pin_data, uint8_t *port, uint8_t nbr_ci) + { + this->pin_clk = pin_clk; + this->pin_data = pin_data; + this->port = port; + this->nbr_ci = nbr_ci; + data = calloc(3*nbr_ci, 1); + ddr = port-1; + *ddr |= (1<pin_clk = pin_clk; + this->pin_data = pin_data; + this->port = port; + this->nbr_ci = nbr_ci; + data = realloc(data,3*nbr_ci); + ddr = port-1; + *ddr |= (1< + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.CPP + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega328P + none + Executable + CPP + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + ws2801 + ws2801 + ws2801 + Native + true + false + true + true + + + true + + 2 + 0 + + + + + + + + + + + + + + + + + -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize for size (-Os) + True + True + True + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + + + + + + + -mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\gcc\dev\atmega328p" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize (-O1) + True + True + Default (-g2) + True + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.1.130\include + + + Default (-Wa,-g) + + + + + + compile + + + + \ No newline at end of file diff --git a/ws2801.h b/ws2801.h new file mode 100644 index 0000000..5d777cc --- /dev/null +++ b/ws2801.h @@ -0,0 +1,30 @@ +/* + * ws2801.h + * + * Created: 26-12-16 21:57:26 + * Author: Adrien + */ + + +#ifndef WS2801_H_ +#define WS2801_H_ + +typedef enum {RED, GREEN, BLUE} Color; + +class ws2801 +{ + private: + uint8_t pin_ckl, pin_data; + uint8_t *data; + uint8_t nbr_ci; + uint8_t *port, *ddr; + public: + ws2801(uint8_t pin_clk, uint8_t pin_data, uint8_t *port); + void conf(uint8_t pin_clk, uint8_t pin_data, uint8_t *port); + void toSend(uint8_t ciN, uint8_t val, Color couleur); + void send(); + void senRaw(uint8_t *data,uint8_t size); +}; + + +#endif /* WS2801_H_ */ \ No newline at end of file