Mise au point interface v3 et Driver
This commit is contained in:
parent
6dcfbb7bd2
commit
d93631e6d6
4 changed files with 245 additions and 80 deletions
|
|
@ -127,7 +127,7 @@ namespace DMX2
|
|||
serial = null;
|
||||
}
|
||||
if (!System.IO.File.Exists (portname)) {
|
||||
Thread.Sleep (200);
|
||||
Thread.Sleep (1500);
|
||||
return;
|
||||
}
|
||||
serial = new SerialPort (portname);//, 9600, Parity.None, 8, StopBits.One);
|
||||
|
|
@ -136,10 +136,9 @@ namespace DMX2
|
|||
//serial.ReadTimeout = 200;
|
||||
//serial.WriteTimeout = 200;
|
||||
try {
|
||||
serial.RtsEnable = true;
|
||||
serial.Open ();
|
||||
serial.RtsEnable = true;
|
||||
serial.DtrEnable = true;
|
||||
Attente(DateTime.Now.AddMilliseconds(2000));
|
||||
//Attente(DateTime.Now.AddMilliseconds(100));
|
||||
|
||||
if(Synchronisation())
|
||||
etat = etatAutomate.Transmission;
|
||||
|
|
@ -151,7 +150,7 @@ namespace DMX2
|
|||
} catch (Exception ex) {
|
||||
etat = etatAutomate.Deconnecte;
|
||||
Console.WriteLine("DriverV3:Connection : {0}",ex);
|
||||
Thread.Sleep (500);
|
||||
Thread.Sleep (1500);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,10 +170,10 @@ namespace DMX2
|
|||
|
||||
// Au cas ou le boitier attends une fin de commande : envoi 1030 octets a 0 (le boitier ignorera tout seul la suite)
|
||||
byte[] tmpBuffer = new byte[530];
|
||||
serial.Write (tmpBuffer, 0, 530);
|
||||
//serial.Write (tmpBuffer, 0, 530);
|
||||
|
||||
// On attends un peu
|
||||
Thread.Sleep (300);
|
||||
Thread.Sleep (100);
|
||||
|
||||
// Vide le buffer d'entree
|
||||
if (serial.BytesToRead > 0)
|
||||
|
|
@ -330,7 +329,7 @@ namespace DMX2
|
|||
serial.ReadExisting ();
|
||||
|
||||
ProcessData();
|
||||
|
||||
//Console.WriteLine("DriverV3.Reception : OK");
|
||||
compteErreur= 0;
|
||||
} catch (Exception ex) {
|
||||
Console.WriteLine(serial.BytesToRead);
|
||||
|
|
@ -341,6 +340,7 @@ namespace DMX2
|
|||
|
||||
void Parametrage ()
|
||||
{
|
||||
Console.WriteLine ("DriverV3.Parametrage()");
|
||||
paramFlag = false;
|
||||
|
||||
if (!serial.IsOpen) {
|
||||
|
|
@ -439,7 +439,7 @@ namespace DMX2
|
|||
Dictionary<int,byte> lastVal = new Dictionary<int, byte>();
|
||||
|
||||
static System.Text.RegularExpressions.Regex regexEventID = new System.Text.RegularExpressions.Regex(
|
||||
@"BV2-D(?<dmx>\d+)?",
|
||||
@"BV3-D(?<dmx>\d+)?",
|
||||
System.Text.RegularExpressions.RegexOptions.Compiled);
|
||||
|
||||
System.Collections.Concurrent.ConcurrentQueue<dmxState> eventsPending =
|
||||
|
|
@ -501,7 +501,7 @@ namespace DMX2
|
|||
if(c+d+u==0) continue;
|
||||
if(c+d+u>512) break;
|
||||
Gtk.MenuItem uitem = new Gtk.MenuItem(string.Format("Entrée DMX {0}",c+d+u));
|
||||
uitem.Data[EventManager.EventIdKey] = string.Format("BV2-D{0}",c+d+u);
|
||||
uitem.Data[EventManager.EventIdKey] = string.Format("BV3-D{0}",c+d+u);
|
||||
uitem.Data[EventManager.StateKey] = state;
|
||||
uitem.ButtonPressEvent += handler;
|
||||
dmenu.Add (uitem);
|
||||
|
|
@ -518,7 +518,7 @@ namespace DMX2
|
|||
dmxState dmxs;
|
||||
EventData evd;
|
||||
while (eventsPending.TryDequeue(out dmxs)) {
|
||||
evd.id= string.Format("BV2-D{0}",dmxs.dmx );
|
||||
evd.id= string.Format("BV3-D{0}",dmxs.dmx );
|
||||
evd.value = dmxs.value;
|
||||
callback(evd);
|
||||
}
|
||||
|
|
@ -526,7 +526,7 @@ namespace DMX2
|
|||
|
||||
string IEventProvider.MenuName {
|
||||
get {
|
||||
return "Boitier V2";
|
||||
return "Boitier V3";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
92
arduino-hardware.patch
Normal file
92
arduino-hardware.patch
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
diff -ur a/hardware/arduino/cores/arduino/CDC.cpp b/hardware/arduino/cores/arduino/CDC.cpp
|
||||
--- a/hardware/arduino/cores/arduino/CDC.cpp 2012-10-02 21:28:19.000000000 +0200
|
||||
+++ b/hardware/arduino/cores/arduino/CDC.cpp 2014-05-05 15:00:45.714075984 +0200
|
||||
@@ -138,6 +138,11 @@
|
||||
{
|
||||
}
|
||||
|
||||
+void WEAK CDC_accept(void)
|
||||
+{
|
||||
+ Serial.accept();
|
||||
+}
|
||||
+
|
||||
void Serial_::accept(void)
|
||||
{
|
||||
ring_buffer *buffer = &cdc_rx_buffer;
|
||||
diff -ur a/hardware/arduino/cores/arduino/USBAPI.h b/hardware/arduino/cores/arduino/USBAPI.h
|
||||
--- a/hardware/arduino/cores/arduino/USBAPI.h 2012-10-02 21:28:19.000000000 +0200
|
||||
+++ b/hardware/arduino/cores/arduino/USBAPI.h 2014-05-05 11:52:14.345644654 +0200
|
||||
@@ -174,6 +174,8 @@
|
||||
int CDC_GetDescriptor(int i);
|
||||
bool CDC_Setup(Setup& setup);
|
||||
|
||||
+void CDC_accept(void);
|
||||
+
|
||||
//================================================================================
|
||||
//================================================================================
|
||||
|
||||
@@ -192,4 +194,4 @@
|
||||
|
||||
#endif
|
||||
|
||||
-#endif /* if defined(USBCON) */
|
||||
\ Pas de fin de ligne à la fin du fichier
|
||||
+#endif /* if defined(USBCON) */
|
||||
diff -ur a/hardware/arduino/cores/arduino/USBCore.cpp b/hardware/arduino/cores/arduino/USBCore.cpp
|
||||
--- a/hardware/arduino/cores/arduino/USBCore.cpp 2012-10-02 21:28:19.000000000 +0200
|
||||
+++ b/hardware/arduino/cores/arduino/USBCore.cpp 2014-05-05 14:07:31.033024833 +0200
|
||||
@@ -49,19 +49,19 @@
|
||||
0x0409 // English
|
||||
};
|
||||
|
||||
-const u16 STRING_IPRODUCT[17] = {
|
||||
- (3<<8) | (2+2*16),
|
||||
+const u16 STRING_IPRODUCT[13] = {
|
||||
+ (3<<8) | (2+2*12),
|
||||
#if USB_PID == 0x8036
|
||||
- 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
|
||||
+ 'D','M','X','v','3',' ','M','i','c','r','o'
|
||||
#else
|
||||
'U','S','B',' ','I','O',' ','B','o','a','r','d',' ',' ',' ',' '
|
||||
#endif
|
||||
};
|
||||
|
||||
-const u16 STRING_IMANUFACTURER[12] = {
|
||||
- (3<<8) | (2+2*11),
|
||||
+const u16 STRING_IMANUFACTURER[11] = {
|
||||
+ (3<<8) | (2+2*10),
|
||||
#if USB_VID == 0x2341
|
||||
- 'A','r','d','u','i','n','o',' ','L','L','C'
|
||||
+ 'L','o','u','p','i','o','t','t','e','s'
|
||||
#else
|
||||
'U','n','k','n','o','w','n',' ',' ',' ',' '
|
||||
#endif
|
||||
@@ -604,13 +604,13 @@
|
||||
#ifdef CDC_ENABLED
|
||||
USB_Flush(CDC_TX); // Send a tx frame if found
|
||||
while (USB_Available(CDC_RX)) // Handle received bytes (if any)
|
||||
- Serial.accept();
|
||||
+ CDC_accept();
|
||||
#endif
|
||||
|
||||
// check whether the one-shot period has elapsed. if so, turn off the LED
|
||||
- if (TxLEDPulse && !(--TxLEDPulse))
|
||||
+ //if (TxLEDPulse && !(--TxLEDPulse))
|
||||
TXLED0;
|
||||
- if (RxLEDPulse && !(--RxLEDPulse))
|
||||
+ //if (RxLEDPulse && !(--RxLEDPulse))
|
||||
RXLED0;
|
||||
}
|
||||
}
|
||||
diff -ur a/hardware/arduino/cores/arduino/USBDesc.h b/hardware/arduino/cores/arduino/USBDesc.h
|
||||
--- a/hardware/arduino/cores/arduino/USBDesc.h 2012-10-02 21:28:19.000000000 +0200
|
||||
+++ b/hardware/arduino/cores/arduino/USBDesc.h 2014-05-05 14:00:00.523148732 +0200
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#define CDC_ENABLED
|
||||
-#define HID_ENABLED
|
||||
+//#define HID_ENABLED
|
||||
|
||||
|
||||
#ifdef CDC_ENABLED
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
#include "USBDesc.h"
|
||||
#include "Platform.h"
|
||||
#include <avr/wdt.h>
|
||||
|
||||
// definition des fonction cbi sbi idem assembleur
|
||||
#ifndef cbi
|
||||
|
|
@ -27,15 +29,82 @@ byte brk_timer_end=75; // def : 150us
|
|||
byte mab_timer_end=25; //def : 50us
|
||||
int nb_circuits=512;
|
||||
int flag_merge1=1;
|
||||
int emissionPc=1;
|
||||
volatile int emissionPc=0;
|
||||
|
||||
|
||||
/* ------------ Gestion Liaison USB -------------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 dwDTERate;
|
||||
u8 bCharFormat;
|
||||
u8 bParityType;
|
||||
u8 bDataBits;
|
||||
u8 lineState;
|
||||
} LineInfo;
|
||||
|
||||
static volatile LineInfo _usbLineInfo = { 500000, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
// Surcharge de la fonction de gestion d'état de ligne de l'emulation série
|
||||
bool CDC_Setup(Setup& setup)
|
||||
{
|
||||
u8 r = setup.bRequest;
|
||||
u8 requestType = setup.bmRequestType;
|
||||
|
||||
if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
|
||||
{
|
||||
if (CDC_GET_LINE_CODING == r)
|
||||
{
|
||||
USB_SendControl(0,(void*)&_usbLineInfo,7);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
|
||||
{
|
||||
if (CDC_SET_LINE_CODING == r)
|
||||
{
|
||||
USB_RecvControl((void*)&_usbLineInfo,7);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CDC_SET_CONTROL_LINE_STATE == r)
|
||||
{
|
||||
_usbLineInfo.lineState = setup.wValueL;
|
||||
|
||||
// Gestion de l'auto-reset : utile pour le programmateur arduino
|
||||
if (1200 == _usbLineInfo.dwDTERate) {
|
||||
if ((_usbLineInfo.lineState & 0x01) == 0) {
|
||||
*(uint16_t *)0x0800 = 0x7777;
|
||||
wdt_enable(WDTO_120MS);
|
||||
} else {
|
||||
wdt_disable();
|
||||
wdt_reset();
|
||||
*(uint16_t *)0x0800 = 0x0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// lancé par interruption USB sur reception d'un char
|
||||
void CDC_accept()
|
||||
{
|
||||
int c = USB_Recv(CDC_RX);
|
||||
litUSB(c);
|
||||
}
|
||||
|
||||
/* ------------ Fin Gestion Liaison USB -------------- */
|
||||
|
||||
// lecture d'un caractere sur USB
|
||||
void litSerial()
|
||||
void litUSB(char c)
|
||||
{
|
||||
char c;
|
||||
//char c;
|
||||
byte *pb, *pe;
|
||||
|
||||
c = Serial.read();
|
||||
|
||||
switch (etat_input_pc) {
|
||||
|
||||
case 0:
|
||||
|
|
@ -70,14 +139,15 @@ void litSerial()
|
|||
|
||||
}
|
||||
// Esc 'B' parametrage
|
||||
if (c==66) {etat_input_pc=10; }
|
||||
if (c==66) {etat_input_pc=10;
|
||||
}
|
||||
|
||||
// Esc 'A' probe
|
||||
if (c==65) {etat_input_pc=0;
|
||||
tab_input_dmx[517]=65;
|
||||
index_output_pc=517; // on init l'index d'emmission vers le pc ( uniquement etat : 65 'A' )
|
||||
emissionPc=1;
|
||||
digitalWrite(ledPin, HIGH);
|
||||
|
||||
}
|
||||
|
||||
// si aucune commande n'est trouvée (toujours à 1) on repart à 0
|
||||
|
|
@ -90,14 +160,16 @@ void litSerial()
|
|||
index_input_pc++;
|
||||
// si on arrive à 512
|
||||
if (index_input_pc > 512) {// on se prépare à emmetre vers le pc
|
||||
etat_input_pc=0;
|
||||
digitalWrite(ledPin, HIGH);
|
||||
etat_input_pc=0;
|
||||
digitalWrite(ledPin, HIGH);
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 10: // 1er parametre : nb de circuits / 2 - 1 ( de 2 a 512 )
|
||||
etat_input_pc++;
|
||||
|
||||
//nb_circuits= ((int)c)*2 + 2;
|
||||
break;
|
||||
|
||||
|
|
@ -128,6 +200,19 @@ void litSerial()
|
|||
|
||||
}
|
||||
|
||||
void ecritUSB()
|
||||
{
|
||||
if(index_output_pc > 516){
|
||||
USB_Send(CDC_TX,tab_input_dmx+index_output_pc,1);
|
||||
emissionPc=0;
|
||||
return;
|
||||
}
|
||||
index_output_pc+= USB_Send(CDC_TX,tab_input_dmx+index_output_pc, 517-index_output_pc);
|
||||
if (index_output_pc>516) {
|
||||
emissionPc=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// vecteur d'intéruption pour reception dmx
|
||||
ISR(USART1_RX_vect)
|
||||
|
|
@ -169,20 +254,6 @@ ISR(USART1_UDRE_vect)
|
|||
|
||||
}
|
||||
|
||||
|
||||
// vecteur d'intéruption pour transmission vers le pc sur serial 0
|
||||
// vecteur registre de transmission
|
||||
void ecritSerial()
|
||||
{
|
||||
//caratère suivant
|
||||
Serial.write(tab_input_dmx[index_output_pc]);
|
||||
index_output_pc++;
|
||||
if (index_output_pc>516) {
|
||||
digitalWrite(ledPin, LOW);
|
||||
emissionPc=0;
|
||||
}
|
||||
}
|
||||
|
||||
ISR(TIMER4_COMPA_vect) {
|
||||
if (index_output_dmx==-2 ) {
|
||||
digitalWrite(tx1pin, HIGH); // on met la broche 18 à 1 pendant 10 µs
|
||||
|
|
@ -207,15 +278,13 @@ ISR(TIMER4_COMPA_vect) {
|
|||
|
||||
void setup() {
|
||||
// initialisation du stat code à 0
|
||||
etat_input_pc=0;
|
||||
tab_input_pc[0]=0;
|
||||
|
||||
// init pin led interne en sortie
|
||||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
|
||||
Serial.begin(9600);
|
||||
/*
|
||||
digitalWrite(ledPin, LOW);
|
||||
// initialisation à 250k de serial 1
|
||||
// baudrate
|
||||
UCSR1A = 1 << U2X1;
|
||||
|
|
@ -246,8 +315,6 @@ void setup() {
|
|||
TC4H=0;
|
||||
|
||||
sei();
|
||||
|
||||
|
||||
|
||||
// préparation du premier break
|
||||
index_output_dmx=-1;
|
||||
|
|
@ -257,13 +324,9 @@ void setup() {
|
|||
// DDRC = 0;
|
||||
tab_input_dmx[533]=0;
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
void loop() {
|
||||
/* Serial.write(65);
|
||||
delay(300);*/
|
||||
/*
|
||||
// génération du break en tache principale
|
||||
int cpt = 0;
|
||||
if (index_output_dmx==-1 ) {
|
||||
|
|
@ -283,17 +346,18 @@ void loop() {
|
|||
tab_input_dmx[514]= 0;
|
||||
tab_input_dmx[515]=0;
|
||||
tab_input_dmx[516]=0;
|
||||
|
||||
*/
|
||||
if(Serial.available()){
|
||||
|
||||
litSerial();
|
||||
}
|
||||
|
||||
if(emissionPc==1) {
|
||||
ecritSerial();
|
||||
}
|
||||
|
||||
if(_usbLineInfo.lineState) { // Si port ouvert
|
||||
if(emissionPc!=0) {
|
||||
ecritUSB();
|
||||
}
|
||||
} else {
|
||||
// Si port fermé : on eteint la LED
|
||||
digitalWrite(ledPin, LOW);
|
||||
// et on réinitialise l'état d'entrée USB
|
||||
etat_input_pc=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
// definition des fonction cbi sbi idem assembleur
|
||||
#ifndef cbi
|
||||
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
|
||||
|
|
@ -26,6 +25,10 @@
|
|||
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
|
||||
#endif
|
||||
|
||||
#include "USBAPI.h"
|
||||
#include "USBDesc.h"
|
||||
|
||||
|
||||
// déclaration des tableaux de données
|
||||
byte tab_input_pc[1026]; // venant du pc
|
||||
byte tab_input_dmx[534]; // données venant de l'extérieur : les 512 premiers DMX; les 20 suivant 4x8 bp + 16 analogique 8bits ; 1 octet d'etat
|
||||
|
|
@ -50,9 +53,14 @@ int flag_merge1=1;
|
|||
int flag_merge2=1;
|
||||
|
||||
|
||||
void acceptchar(char c)
|
||||
{
|
||||
|
||||
USB_Flush(CDC_TX);
|
||||
}
|
||||
|
||||
// vecteur d'inéruption pour reception pc
|
||||
|
||||
/*
|
||||
ISR(USART0_RX_vect)
|
||||
{
|
||||
char c,r;
|
||||
|
|
@ -148,7 +156,7 @@ ISR(USART0_RX_vect)
|
|||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// vecteur d'intéruption pour reception dmx
|
||||
|
|
@ -189,7 +197,7 @@ ISR(USART1_UDRE_vect)
|
|||
if (index_output_dmx>nb_circuits) {index_output_dmx=-4;cbi(UCSR1B, UDRIE1);}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// vecteur d'intéruption pour transmission DMX sur serial 2
|
||||
// vecteur : USART 1 transmission buffer vide
|
||||
ISR(USART2_TX_vect)
|
||||
|
|
@ -221,7 +229,7 @@ ISR(USART0_UDRE_vect)
|
|||
if (index_output_pc>532) {
|
||||
cbi(UCSR0B, UDRIE0);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
ISR(TIMER2_OVF_vect) {
|
||||
if (index_output_dmx==-2 ) {
|
||||
|
|
@ -239,9 +247,9 @@ ISR(TIMER2_OVF_vect) {
|
|||
index_output_dmx=0; // on se prépare à émmettre à partir du stat code ( 513 octets )
|
||||
sbi(UCSR1B, UDRIE1); // on réactive l'intéruption du registre
|
||||
|
||||
sbi(UCSR2B, TXEN2); // on redémarre la transmission
|
||||
/* sbi(UCSR2B, TXEN2); // on redémarre la transmission
|
||||
index_output_dmx2=0; // on se prépare à émmettre à partir du stat code ( 513 octets )
|
||||
sbi(UCSR2B, UDRIE2); // on réactive l'intéruption du registre
|
||||
sbi(UCSR2B, UDRIE2); // on réactive l'intéruption du registre */
|
||||
|
||||
TIMSK2 = 0 ; //desactivation intéruption A &B
|
||||
TCCR2B = 0;
|
||||
|
|
@ -253,12 +261,13 @@ void setup() {
|
|||
// initialisation du stat code à 0
|
||||
tab_input_pc[0]=0;
|
||||
|
||||
|
||||
|
||||
// initialisation de la liaison série pc à 0,5MB/s
|
||||
//Serial.begin(460800);
|
||||
UCSR0A = 1 << U2X0;
|
||||
/* UCSR0A = 1 << U2X0;
|
||||
UBRR0H=0;
|
||||
UBRR0L = 3;
|
||||
UCSR0C = 6;
|
||||
UCSR0C = 6;*/
|
||||
|
||||
|
||||
// initialisation à 250k de serial 1
|
||||
|
|
@ -270,7 +279,7 @@ void setup() {
|
|||
// 2 bit de stop; pas de parité; 8 bits de données
|
||||
UCSR1C = 14;
|
||||
|
||||
|
||||
/*
|
||||
// initialisation à 250k de serial 2
|
||||
// baudrate
|
||||
UCSR2A = 1 << U2X2;
|
||||
|
|
@ -278,7 +287,7 @@ void setup() {
|
|||
UBRR2L = 7;
|
||||
|
||||
// 2 bit de stop; pas de parité; 8 bits de données
|
||||
UCSR2C = 14;
|
||||
UCSR2C = 14;*/
|
||||
|
||||
// activation transmission et intéruption serial 1
|
||||
sbi(UCSR1B, RXEN1); //Reception
|
||||
|
|
@ -287,24 +296,24 @@ void setup() {
|
|||
sbi(UCSR1B, TXCIE1); //Interruption pour fin de transmission
|
||||
|
||||
// activation transmission et intéruption serial 2
|
||||
sbi(UCSR2B, TXEN2); //Transmission
|
||||
/* sbi(UCSR2B, TXEN2); //Transmission
|
||||
sbi(UCSR2B, TXCIE2); //Interruption pour fin de transmission
|
||||
|
||||
sbi(UCSR0B, RXEN0); //Reception
|
||||
sbi(UCSR0B, RXCIE0); //Interruption sur reception
|
||||
sbi(UCSR0B, TXEN0); //Transmission
|
||||
sbi(UCSR0B, TXEN0); //Transmission*/
|
||||
|
||||
|
||||
// Init convertion analogique pour le premier canal pin0
|
||||
/* // Init convertion analogique pour le premier canal pin0
|
||||
ADCSRB = (ADCSRB & ~(1 << MUX5));
|
||||
ADMUX = 96; //01100000 reférence sur le 5v et alignement pour lecture sur 8 bits
|
||||
sbi(ADCSRA, ADSC);
|
||||
sbi(ADCSRA, ADSC);*/
|
||||
|
||||
// init timer break
|
||||
TIMSK2 = 0;
|
||||
TCCR2B = 0;
|
||||
TCCR2A = 0; // 00000000
|
||||
ASSR &= ~(1<<AS2);
|
||||
// ASSR &= ~(1<<AS2); <---------------------------
|
||||
TCNT2 = 0; // compteur
|
||||
OCR2A = 220 ; // 100µs
|
||||
OCR2B = 200 ; // 110µs
|
||||
|
|
@ -318,10 +327,10 @@ void setup() {
|
|||
// préparation du premier break
|
||||
index_output_dmx=-1;
|
||||
index_output_dmx2=-1;
|
||||
PORTA = 255;
|
||||
DDRA = 0;
|
||||
PORTC = 255;
|
||||
DDRC = 0;
|
||||
// PORTA = 255;
|
||||
// DDRA = 0;
|
||||
// PORTC = 255;
|
||||
// DDRC = 0;
|
||||
tab_input_dmx[533]=0;
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +344,7 @@ void loop() {
|
|||
pinMode(tx1pin, OUTPUT); // on met la broche 18 en mode sortie
|
||||
pinMode(tx2pin, OUTPUT); // on met la broche 16 en mode sortie
|
||||
cbi(UCSR1B, TXEN1); //on stop la transmission
|
||||
cbi(UCSR2B, TXEN2); //on stop la transmission
|
||||
// cbi(UCSR2B, TXEN2); //on stop la transmission
|
||||
digitalWrite(tx1pin, LOW); // on met la broche 18 à 0
|
||||
digitalWrite(tx2pin, LOW); // on met la broche 16 à 0
|
||||
TCNT2 = brk_timer_start ;// RAZ compteur timer
|
||||
|
|
@ -345,18 +354,18 @@ void loop() {
|
|||
} // fin du break
|
||||
|
||||
// suite du code
|
||||
tab_input_dmx[513]= PINA;
|
||||
tab_input_dmx[514]= PINC;
|
||||
// tab_input_dmx[513]= PINA;
|
||||
//tab_input_dmx[514]= PINC;
|
||||
tab_input_dmx[515]=0;
|
||||
tab_input_dmx[516]=0;
|
||||
if ( ! bit_is_set(ADCSRA, ADSC)) {
|
||||
/* if ( ! bit_is_set(ADCSRA, ADSC)) {
|
||||
//digitalWrite(ledPin, HIGH);
|
||||
tab_input_dmx[517+cpt_ana++]=ADCH;
|
||||
if (cpt_ana>15) cpt_ana=0;
|
||||
ADCSRB = (ADCSRB & ~(1 << MUX5)) | (((cpt_ana >> 3) & 0x01) << MUX5);
|
||||
ADMUX = 96 | (cpt_ana & 0x07);
|
||||
sbi(ADCSRA, ADSC);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue