From b275a520faed0f427ab8f0bc2e59ff6e6f686543 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Sun, 10 Nov 2013 17:10:02 +0000 Subject: [PATCH] 20131110-181004 --- Mainboard/Mainboard.atsuo | Bin 15872 -> 23552 bytes Mainboard/Mainboard/Can.h | 6 --- Mainboard/Mainboard/Debug/Can.d | 41 ++++++++-------- Mainboard/Mainboard/Debug/Led.d | 9 +++- Mainboard/Mainboard/Led.cpp | 46 ++++++++---------- Mainboard/Mainboard/Led.h | 47 +++++++++++++++--- Mainboard/Mainboard/Mainboard.cpp | 13 +++-- Mainboard/Mainboard/Mainboard.cppproj | 9 ++++ Mainboard/Mainboard/Spi.cpp | 67 ++++++++++++++------------ Mainboard/Mainboard/Spi.h | 11 ++++- Mainboard/Mainboard/pin.hpp | 48 ++++++++++++++++++ Mainboard/Mainboard/portb.hpp | 22 +++++++++ Mainboard/Mainboard/portc.hpp | 22 +++++++++ 13 files changed, 240 insertions(+), 101 deletions(-) create mode 100644 Mainboard/Mainboard/pin.hpp create mode 100644 Mainboard/Mainboard/portb.hpp create mode 100644 Mainboard/Mainboard/portc.hpp diff --git a/Mainboard/Mainboard.atsuo b/Mainboard/Mainboard.atsuo index 095d318d31437c4e8e16de754dbd779de77f640f..a52161b74df3b3413e51c4732e96d6506e49f9c0 100644 GIT binary patch delta 3649 zcmchZdt6k<702f;cVUs&F0LEiEN>Rr6&6IGRM>*h8V#U{wV!TOT!?H7yUVgDH72Z& zq_o-=I7ymnD`@&KnkbJ{jfoAYwXtawTbm}0lKQ9;KTSWM^us^aexSd(`*2CpfBJ{B z`@J)B=FHrgGiT-=_g41_VW?G>kjxmHnVp?YLaqfVAQf;K^#rHO^LS;rp-$)*mkVLE zUrdgyUz2ILcjbZ*geG?xZ4u9h3h5~GIt>_8XuTLhZiPr)@_KQ>9AT6wiw>cG%SXgF zxqK+NSKP-7)ghJQZ+M|6QRt{DGuJ!q8=Z}9+8S$XbB8v&tE55ak05^le0v>(blPV`IR9uTWyxs z&ZcJGY_{6l3XPpcLknKZn7~GZLQOISUw0(%FUS>Eui%!62oR1=hdnBa837Vkw^H@K+%NaGMucQ35^q^G^D}|@$jGk0~NubblJ*8^a%FJIK zb!&2Dj}@WElgz}7tcERRi&+t#1x(MrB9#kKD!{Lr<)dVh+Ds_r<7Wa@tQ5~0=~u-H z*;CBGn%HKVjTxZoC^Zd=;IA~%) zhTLJb8CobMFDF7^g5YUn*2>S?JxI=~=~C(rzkVgH64e5it)sE@(`x6%UC{+IeOHfs zcu%a%IC_WgV_!oY4P`thD)|fjyPb&{CqTkas(;4QnUW8XE300Sh=!0kjaj>sH`p7U zP3Dyy#zL=y2bbGATU(bv56MKA(n{hTcBji?XmL2W=nL9Cy)FN%J(Ty~!2463Zkczb zGug`}-&>(epz-7i8cJ1@Emx!A_V%QhF+O2_#Hx?cshsWfmkbOFM!r%{RYxFyYIq|t$-B&t*@#H>K29jF`z zNL)!U;&xAz)UvtAdy{uRi^@T+gtQH82mJG}6ZtdV@^_K~};63mc@ILqe{1to%u7ImWcuaziz~8_%a2?zL zH^JY*EpQu5fsesVU&A;1%g2PL;n!U`7RlB3Y`*!ADD}3Co`aLaH*Vax%}*W{C?)PL zl2h$9CJNh0$Y@Xd{8>@Gof|)5k61dft$J#!e&ePfIAyN%3Pktw4f-nWnz*8a)sOP^meQk!|ucK!D87xK7a^6`lly{25r zI`D}t1ioc|<6M?iJ$UrUYxl0{Dn5AcJU5Wfl!4kUY~8}9u{|Hp4qr`M^6D*}#wm@> zEwNadDnHYDJ|o{+pGPIoEG2$5L!jD=sCZW+Exgoc68T=V4B)f*Fjbe9f5sOq{>!mj zZ%hU%)1{$1i8ihywWidaC&G$*h<5{WE$+N}?)7k)-gMh58iv zRFNA(FK4T0y{P?QNli9sAuF%+AmNK)$8wfrT5C}F(fuQu% z&WY_xv>PoJv+e%~1UsH^(xvzQqT+2_5{In-9_z>6-z+?4)4T;g3x2pD@pb zEcI|K@Qv#0$?xtd?<58>qfjy>RZwMYF&)z%l3}ibv1?unlz1@f8ACJoUh%}Z-nR!f a`Cg$!&q>J&VLp>1yc|V5Ezn?j{eJ=JdgyKd delta 1131 zcmY*X-){_26rMYs*_qXLyVK6D-F9_nw_9vgY&AucDi*7ibSe!Z(N_9GN@y|?zry&D zkRaB6eL^U2h*;eO55$H(5JANoul@oy@griL+pU_OuURQ~xLD-#4EZ{Vo(+AUO*&+oXoG=hYrz*Z$3mQ6{S z1y)JoW)Z*Saf!!8)|DE<&oDsHK^zpMVM{SkP=2Pl{?dTHU4A6IbrwR`R8TwVicV8UM zi~T-68~=ocD^ zAyF0cDc=w=o>}YyQ>E4xBTlfe;37WwqSTfEhEwUO_QboZNu$+Uq;*VYnKvOwM>N1b_9(z?UX2ef2?Jg=6En0$m0-)Xe_+PEm% z^cWGL<|}EJp{a{tFJ6Y&_Pgkl4dgeDV60E|?-3UD8TQJ?w}&dmzMlDV;^Yk;?n-YY zmsnE6rkZLcsHp~_4YX#&DkMr`SuLi@M>jT$Y`LJtzZDvX+V+1>pCA7C>A<^w1?iA*9nT|VKj1GnAoriMmWh&`4qvY TajSjc;ox #include #include "mcp2515_defs.h" -#include "Led.h" #include "Spi.h" #ifndef CAN_H_ #define CAN_H_ -//#define DDR_CS DDRB -//#define PORT_CS PORTB -//#define P_CS 2 - typedef struct { uint16_t id; diff --git a/Mainboard/Mainboard/Debug/Can.d b/Mainboard/Mainboard/Debug/Can.d index 9216409..8ac21a5 100644 --- a/Mainboard/Mainboard/Debug/Can.d +++ b/Mainboard/Mainboard/Debug/Can.d @@ -1,27 +1,26 @@ Can.d Can.o: .././Can.cpp .././Can.h .././config.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h \ + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/inttypes.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/include/stdint.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/stdint.h \ + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay_basic.h \ + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/math.h \ + .././mcp2515_defs.h .././Spi.h \ + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h \ + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/iom32u2.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/portpins.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/common.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/version.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/fuse.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay_basic.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/math.h \ - .././mcp2515_defs.h .././Led.h .././Spi.h + .././pin.hpp .././portb.hpp .././Can.h: .././config.h: -c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h: - -c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h: +c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/inttypes.h: @@ -29,6 +28,18 @@ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8- c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/stdint.h: +c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay_basic.h: + +c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/math.h: + +.././mcp2515_defs.h: + +.././Spi.h: + +c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h: + +c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h: + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/iom32u2.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/portpins.h: @@ -41,14 +52,6 @@ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8- c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h: -c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h: +.././pin.hpp: -c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay_basic.h: - -c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/math.h: - -.././mcp2515_defs.h: - -.././Led.h: - -.././Spi.h: +.././portb.hpp: diff --git a/Mainboard/Mainboard/Debug/Led.d b/Mainboard/Mainboard/Debug/Led.d index ff93166..766f986 100644 --- a/Mainboard/Mainboard/Debug/Led.d +++ b/Mainboard/Mainboard/Debug/Led.d @@ -1,4 +1,4 @@ -Led.d Led.o: .././Led.cpp .././Led.h \ +Led.d Led.o: .././Led.cpp .././Led.h .././portc.hpp \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/inttypes.h \ @@ -9,10 +9,13 @@ Led.d Led.o: .././Led.cpp .././Led.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/common.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/version.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/fuse.h \ - c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h \ + .././pin.hpp .././Led.h: +.././portc.hpp: + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h: @@ -34,3 +37,5 @@ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8- c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/fuse.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h: + +.././pin.hpp: diff --git a/Mainboard/Mainboard/Led.cpp b/Mainboard/Mainboard/Led.cpp index b1bdadb..f14e3c0 100644 --- a/Mainboard/Mainboard/Led.cpp +++ b/Mainboard/Mainboard/Led.cpp @@ -1,49 +1,41 @@ /* - * CPPFile1.cpp + * Led.cpp * * Created: 03.11.2013 17:24:58 * Author: netz */ #include "Led.h" -#define LEDPORT PORTB -#define LEDDDR DDRB -#define LEDPINR PINC5 -#define LEDPING PINC6 -#define LEDPINB PINC7 -#define LEDPINM PINC5 -Led::Led() { +/*Led::Led() { init(); -} +}*/ -void Led::init() { - LEDDDR |= (1< +#include "portc.hpp" +#include "pin.hpp" #ifndef LED_H_ #define LED_H_ - +template class Led { public: - Led(); + Led() { + init(); + } inline Led(int) {} - //virtual ~Led(); - void color(uint8_t mask); - void rainbow(uint8_t time); - void fade(int from, int to, int dur); + void color(uint8_t mask) { + (mask & (1<<0)) ? blue::make_high() : blue::make_low(); + (mask & (1<<1)) ? green::make_high() : green::make_low(); + (mask & (1<<2)) ? red::make_high() : red::make_low(); + } + void rainbow(uint8_t time) { + fade(RED, YELLOW, time); + fade(YELLOW, GREEN, time); + fade(GREEN, CYAN, time); + fade(CYAN, BLUE, time); + fade(BLUE, MAGENTA, time); + fade(MAGENTA, RED, time); + } + void fade(uint8_t from, uint8_t to, uint8_t dur) { + for (uint8_t i=0;i<0xFF;i++) { + for(uint8_t k=0;k red; + const typedef avrlib::pin green; + const typedef avrlib::pin blue; }; diff --git a/Mainboard/Mainboard/Mainboard.cpp b/Mainboard/Mainboard/Mainboard.cpp index 86d12f8..a921cff 100644 --- a/Mainboard/Mainboard/Mainboard.cpp +++ b/Mainboard/Mainboard/Mainboard.cpp @@ -10,15 +10,18 @@ #include "Rs232.h" #include "Can.h" #include "Spi.h" +#include "portc.hpp" #include -Led l; +//Led l; +typedef Led l; Rs232 r; Can c(Spi(0)); int main(void) { - l.color(Led::YELLOW); + //l.color(Led::YELLOW); + l::color(l::YELLOW); r.send("bla\n"); CANMessage m; m.id = 0x0123; @@ -28,7 +31,7 @@ int main(void) m.data[1] = 0xFE; while(1) { - l.color(Led::GREEN); + //l.color(Led::GREEN); _delay_ms(100); //r.send("Text\n"); //_delay_ms(500); @@ -39,10 +42,10 @@ int main(void) //c.can_send_message(&m); uint8_t r = c.can_get_message(&m); if(r == 0xFF) { - l.color(Led::RED); + //l.color(Led::RED); _delay_ms(100); } else { - l.color(Led::BLUE); + //l.color(Led::BLUE); _delay_ms(1000); } } diff --git a/Mainboard/Mainboard/Mainboard.cppproj b/Mainboard/Mainboard/Mainboard.cppproj index 70af7c5..c1f711d 100644 --- a/Mainboard/Mainboard/Mainboard.cppproj +++ b/Mainboard/Mainboard/Mainboard.cppproj @@ -165,6 +165,15 @@ compile + + compile + + + compile + + + compile + compile diff --git a/Mainboard/Mainboard/Spi.cpp b/Mainboard/Mainboard/Spi.cpp index a0b521f..4ef00e5 100644 --- a/Mainboard/Mainboard/Spi.cpp +++ b/Mainboard/Mainboard/Spi.cpp @@ -18,20 +18,23 @@ void Spi::init() { } } -#define CANDDR_SPI DDRB +/*#define CANDDR_SPI DDRB #define CANPORT_SPI PORTB #define CANPIN_SPI PINB #define CANP_MISO PINB3 #define CANP_MOSI PINB2 #define CANP_SCK PINB1 -#define CANP_CS PINB4 +#define CANP_CS PINB4*/ void Spi::init_port() { - CANDDR_SPI |= (1<0; a--){ //das Byte wird Bitweise nacheinander Gesendet MSB zuerst + datain<<=1; //Schieben um das Richtige Bit zusetzen + sck::make_low(); // Clock auf LOW + if (data & 0x80) { //Ist Bit a in Byte gesetzt + mosi::make_high(); //Set Output High + } + else{ + mosi::make_low(); //Set Output Low + } + _delay_us(1); + if(miso::read()) //Lesen des Pegels + { + datain |= 1; + } + _delay_us(1); + sck::make_high(); // Clock auf High + _delay_us(2); + data<<=1; //Schiebe um nächstes Bit zusenden + } + return datain; + /*uint8_t werti = 0; for (uint8_t i = 8; i != 0; i--) { CANPORT_SPI = (CANPORT_SPI & (~(1 << CANP_MOSI))) | ((data & 1) << CANP_MOSI); @@ -79,26 +103,5 @@ uint8_t Spi::send_soft(uint8_t data) { asm volatile ("nop"); werti = (werti << 1) | ((CANPIN_SPI >> CANP_MISO) & 1); } - //RF_PORT &= ~(1< +#include +#include "pin.hpp" +#include "portb.hpp" + class Spi { public: @@ -19,8 +24,10 @@ class Spi { uint8_t send(uint8_t data); private: const uint8_t mode; //0 Hardware, 1 Software - volatile uint8_t *canport; - //static uint8_t spiport = PORTB; + const typedef avrlib::pin cs; + const typedef avrlib::pin miso; + const typedef avrlib::pin mosi; + const typedef avrlib::pin sck; void init(); void init_port(); void init_spi(); diff --git a/Mainboard/Mainboard/pin.hpp b/Mainboard/Mainboard/pin.hpp new file mode 100644 index 0000000..f0427b6 --- /dev/null +++ b/Mainboard/Mainboard/pin.hpp @@ -0,0 +1,48 @@ +#ifndef AVRLIB_PIN_HPP +#define AVRLIB_PIN_HPP + +namespace avrlib { + + template + struct pin + { + static void set(bool value = true) + { + if (value) + Port::port(Port::port() | (1< + +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + }; + +} + +#endif diff --git a/Mainboard/Mainboard/portc.hpp b/Mainboard/Mainboard/portc.hpp new file mode 100644 index 0000000..017e95b --- /dev/null +++ b/Mainboard/Mainboard/portc.hpp @@ -0,0 +1,22 @@ +#ifndef AVRLIB_PORTC_HPP +#define AVRLIB_PORTC_HPP + +#include + +namespace avrlib { + + struct portc + { + static uint8_t port() { return PORTC; } + static void port(uint8_t v) { PORTC = v; } + + static uint8_t pin() { return PINC; } + static void pin(uint8_t v) { PINC = v; } + + static uint8_t dir() { return DDRC; } + static void dir(uint8_t v) { DDRC = v; } + }; + +} + +#endif