mirror of https://github.com/EspoTek/Labrador.git
Quick PCB finalisationsion, lowered priority of tiny_dma_set_mode_x; looks like it's stopped the problem of "too much switching drops packet
This commit is contained in:
parent
66a8b96e10
commit
c5e94e6812
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1110,32 +1110,7 @@ static bool udc_reqvend(void){
|
|||
udd_set_setup_payload(dacBuf_CH1, udd_g_ctrlreq.req.wLength);
|
||||
if(dacBuf_len != udd_g_ctrlreq.req.wLength){
|
||||
dacBuf_len = udd_g_ctrlreq.req.wLength;
|
||||
switch(global_mode){
|
||||
case 0:
|
||||
tiny_dma_set_mode_0();
|
||||
break;
|
||||
case 1:
|
||||
tiny_dma_set_mode_1();
|
||||
break;
|
||||
case 2:
|
||||
tiny_dma_set_mode_2();
|
||||
break;
|
||||
case 3:
|
||||
tiny_dma_set_mode_3();
|
||||
break;
|
||||
case 4:
|
||||
tiny_dma_set_mode_4();
|
||||
break;
|
||||
case 5:
|
||||
tiny_dma_set_mode_5();
|
||||
break;
|
||||
case 6:
|
||||
tiny_dma_set_mode_6();
|
||||
break;
|
||||
case 7:
|
||||
tiny_dma_set_mode_7();
|
||||
break;
|
||||
}
|
||||
tiny_dma_delayed_set(global_mode);
|
||||
}
|
||||
return 1;
|
||||
case 0xa2: //CH2 waveform
|
||||
|
@ -1145,32 +1120,7 @@ static bool udc_reqvend(void){
|
|||
udd_set_setup_payload(dacBuf_CH2, udd_g_ctrlreq.req.wLength);
|
||||
if(auxDacBufLen != udd_g_ctrlreq.req.wLength){
|
||||
auxDacBufLen = udd_g_ctrlreq.req.wLength;
|
||||
switch(global_mode){
|
||||
case 0:
|
||||
tiny_dma_set_mode_0();
|
||||
break;
|
||||
case 1:
|
||||
tiny_dma_set_mode_1();
|
||||
break;
|
||||
case 2:
|
||||
tiny_dma_set_mode_2();
|
||||
break;
|
||||
case 3:
|
||||
tiny_dma_set_mode_3();
|
||||
break;
|
||||
case 4:
|
||||
tiny_dma_set_mode_4();
|
||||
break;
|
||||
case 5:
|
||||
tiny_dma_set_mode_5();
|
||||
break;
|
||||
case 6:
|
||||
tiny_dma_set_mode_6();
|
||||
break;
|
||||
case 7:
|
||||
tiny_dma_set_mode_7();
|
||||
break;
|
||||
}
|
||||
tiny_dma_delayed_set(global_mode);
|
||||
}
|
||||
return 1;
|
||||
case 0xa3: //PSU voltage control
|
||||
|
@ -1185,39 +1135,39 @@ static bool udc_reqvend(void){
|
|||
case 0: //Mode 0
|
||||
tiny_adc_setup(0, 0);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
|
||||
tiny_dma_set_mode_0();
|
||||
tiny_dma_delayed_set(0);
|
||||
break;
|
||||
case 1: //Mode 1
|
||||
tiny_adc_setup(0, 0);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
|
||||
tiny_dma_set_mode_1();
|
||||
tiny_dma_delayed_set(1);
|
||||
break;
|
||||
case 2: //Mode 2
|
||||
tiny_adc_setup(1, 1);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
|
||||
tiny_adc_ch1setup(udd_g_ctrlreq.req.wIndex>>8);
|
||||
tiny_dma_set_mode_2();
|
||||
tiny_dma_delayed_set(2);
|
||||
break;
|
||||
case 3: //Mode 3
|
||||
tiny_dma_set_mode_3();
|
||||
tiny_dma_delayed_set(3);
|
||||
break;
|
||||
case 4: //Mode 4
|
||||
tiny_dma_set_mode_4();
|
||||
tiny_dma_delayed_set(4);
|
||||
break;
|
||||
case 5: //Mode 5
|
||||
tiny_adc_setup(0, 0);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
|
||||
tiny_dma_set_mode_5();
|
||||
tiny_dma_delayed_set(5);
|
||||
break;
|
||||
case 6: //Mode 6
|
||||
tiny_adc_setup(0, 1);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex);
|
||||
tiny_dma_set_mode_6();
|
||||
tiny_dma_delayed_set(6);
|
||||
break;
|
||||
case 7: //Mode 7
|
||||
tiny_adc_setup(0, 2);
|
||||
tiny_adc_ch0setup(udd_g_ctrlreq.req.wIndex | 0x80);
|
||||
tiny_dma_set_mode_7();
|
||||
tiny_dma_delayed_set(7);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
@ -56,6 +56,10 @@ extern volatile unsigned int median_TRFCNT;
|
|||
extern volatile unsigned short dma_ch0_ran;
|
||||
extern volatile unsigned short dma_ch1_ran;
|
||||
|
||||
extern volatile unsigned char futureMode;
|
||||
extern volatile unsigned char modeChanged;
|
||||
|
||||
|
||||
#include "unified_debug_structure.h"
|
||||
extern unified_debug uds;
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ volatile char debug_data[8] = "DEBUG123";
|
|||
volatile unsigned short dma_ch0_ran;
|
||||
volatile unsigned short dma_ch1_ran;
|
||||
|
||||
volatile unsigned char futureMode;
|
||||
volatile unsigned char modeChanged = 0;
|
||||
|
||||
unified_debug uds;
|
||||
|
||||
int main(void){
|
||||
|
@ -84,10 +87,6 @@ int main(void){
|
|||
strcpy(uds.header, "debug123");
|
||||
|
||||
while (true) {
|
||||
debug_counter++;
|
||||
if(debug_counter > 100000000){
|
||||
debug_counter = 0;
|
||||
}
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
|
@ -102,8 +101,35 @@ int main(void){
|
|||
asm("nop");
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
//test_byte = ADCA.CH1.RESH;
|
||||
//DO NOTHING!
|
||||
if(modeChanged){
|
||||
switch(futureMode){
|
||||
case 0:
|
||||
tiny_dma_set_mode_0();
|
||||
break;
|
||||
case 1:
|
||||
tiny_dma_set_mode_1();
|
||||
break;
|
||||
case 2:
|
||||
tiny_dma_set_mode_2();
|
||||
break;
|
||||
case 3:
|
||||
tiny_dma_set_mode_3();
|
||||
break;
|
||||
case 4:
|
||||
tiny_dma_set_mode_4();
|
||||
break;
|
||||
case 5:
|
||||
tiny_dma_set_mode_5();
|
||||
break;
|
||||
case 6:
|
||||
tiny_dma_set_mode_6();
|
||||
break;
|
||||
case 7:
|
||||
tiny_dma_set_mode_7();
|
||||
break;
|
||||
}
|
||||
modeChanged = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,7 +149,6 @@ void main_resume_action(void)
|
|||
|
||||
void main_sof_action(void)
|
||||
{
|
||||
cli();
|
||||
uds.trfcntL0 = DMA.CH0.TRFCNTL;
|
||||
uds.trfcntH0 = DMA.CH0.TRFCNTH;
|
||||
uds.trfcntL1 = DMA.CH1.TRFCNTL;
|
||||
|
@ -138,7 +163,6 @@ void main_sof_action(void)
|
|||
tiny_calibration_first_sof();
|
||||
firstFrame = 0;
|
||||
tcinit = 1;
|
||||
sei();
|
||||
return;
|
||||
}
|
||||
else{
|
||||
|
@ -169,7 +193,6 @@ void main_sof_action(void)
|
|||
else{
|
||||
usb_state = (DMA.CH0.TRFCNT < 750) ? 1 : 0;
|
||||
}
|
||||
sei();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,12 @@ void tiny_dma_flush(void){
|
|||
dma_ch0_ran = 0;
|
||||
dma_ch1_ran = 0;
|
||||
}
|
||||
void tiny_dma_delayed_set(unsigned char mode){
|
||||
futureMode = mode;
|
||||
modeChanged = 1;
|
||||
}
|
||||
void tiny_dma_set_mode_0(void){
|
||||
cli();
|
||||
|
||||
global_mode = 0;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -101,7 +105,7 @@ void tiny_dma_set_mode_0(void){
|
|||
median_TRFCNT = 200;
|
||||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_0(void){
|
||||
|
@ -109,7 +113,7 @@ void tiny_dma_loop_mode_0(void){
|
|||
}
|
||||
|
||||
void tiny_dma_set_mode_1(void){
|
||||
cli();
|
||||
|
||||
|
||||
global_mode = 1;
|
||||
|
||||
|
@ -191,7 +195,7 @@ void tiny_dma_set_mode_1(void){
|
|||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
sei();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -201,7 +205,7 @@ void tiny_dma_loop_mode_1(void){
|
|||
}
|
||||
|
||||
void tiny_dma_set_mode_2(void){
|
||||
cli();
|
||||
|
||||
global_mode = 2;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -281,7 +285,7 @@ void tiny_dma_set_mode_2(void){
|
|||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_2(void){
|
||||
|
@ -291,7 +295,7 @@ void tiny_dma_loop_mode_2(void){
|
|||
|
||||
|
||||
void tiny_dma_set_mode_3(void){
|
||||
cli();
|
||||
|
||||
global_mode = 3;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -381,7 +385,7 @@ void tiny_dma_set_mode_3(void){
|
|||
//Must enable last for REPCNT won't work!
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_3(void){
|
||||
|
@ -389,7 +393,7 @@ void tiny_dma_loop_mode_3(void){
|
|||
}
|
||||
|
||||
void tiny_dma_set_mode_4(void){
|
||||
cli();
|
||||
|
||||
global_mode = 4;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -471,7 +475,7 @@ void tiny_dma_set_mode_4(void){
|
|||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
DMA.CH1.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_4(void){
|
||||
|
@ -484,7 +488,7 @@ void tiny_dma_set_mode_5(void){
|
|||
}
|
||||
|
||||
void tiny_dma_set_mode_6(void){
|
||||
cli();
|
||||
|
||||
global_mode = 6;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -547,7 +551,7 @@ void tiny_dma_set_mode_6(void){
|
|||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_6(void){
|
||||
|
@ -555,7 +559,7 @@ void tiny_dma_loop_mode_6(void){
|
|||
}
|
||||
|
||||
void tiny_dma_set_mode_7(void){
|
||||
cli();
|
||||
|
||||
global_mode = 7;
|
||||
|
||||
tiny_dma_flush();
|
||||
|
@ -617,7 +621,7 @@ void tiny_dma_set_mode_7(void){
|
|||
median_TRFCNT = 400;
|
||||
median_TRFCNT_delay = 1; //Wait a few frames before actually setting median_TRFCNT, in case a SOF interrupt was queued during tiny_dma_set_mode_xxx.
|
||||
DMA.CH0.CTRLA |= DMA_CH_ENABLE_bm; //Enable!
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
void tiny_dma_loop_mode_7(void){
|
||||
|
|
|
@ -39,8 +39,7 @@ void tiny_dma_loop_mode_6(void);
|
|||
void tiny_dma_set_mode_7(void);
|
||||
void tiny_dma_loop_mode_7(void);
|
||||
|
||||
ISR(DMA_CH3_vect);
|
||||
|
||||
void tiny_dma_delayed_set(unsigned char mode);
|
||||
|
||||
|
||||
#endif /* TINY_DMA_H_ */
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.1.0, 2017-02-05T09:13:08. -->
|
||||
<!-- Written by QtCreator 4.1.0, 2017-02-07T09:45:32. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,7 +2,7 @@ Id,Designator,Package,Quantity,Designation,Description,Notes
|
|||
1,"C6,C9,C15",c_elec_4x5.3,3,CP1,"SMD Electrolytic Capacitor, 33uH 16V","Exact brand is not important but should be reputable (Nichicon, Panasonic, Rubycon etc.)"
|
||||
2,IC1,LQFP-44_10x10mm_Pitch0.8mm,1,ATXMEGA16A4U-A,ATXMEGA32A4U-AU,Please be careful! There is a similar chip called the ATXMEGA32-A4-AU that will cause the product to fail!
|
||||
3,P2,USB_Micro-B_WIDE,1,USB_OTG,Micro USB-B connector,
|
||||
5,"C1,C2,C7,C8,C10,C11,C13,C14,C16,C17,C18",C_0603,11,C,1uF 0603 Ceramic Cap,"Exact brand is not important but should be reputable (Vishay, Kemet, Murata etc.)"
|
||||
5,"C1,C2,C7,C8,C10,C11,C12, C13,C14,C16,C17,C18",C_0603,12,C,1uF 0603 Ceramic Cap,"Exact brand is not important but should be reputable (Vishay, Kemet, Murata etc.)"
|
||||
6,"C3,C4,C5",C_0603,3,C_Small,1uF 0603 Ceramic Cap,"Exact brand is not important but should be reputable (Vishay, Kemet, Murata etc.)"
|
||||
7,D1,SMA_Standard,1,D_Schottky,"SMA Schottky Diode, 1.5V 1A",http://il.farnell.com/multicomp/ss14/schottky-diode-1a-40v-sma-full/dp/1843479
|
||||
8,D2,LED_0603,1,LED,0603 LED,Exact brand is not important but should be reputable.
|
||||
|
|
|
Binary file not shown.
Loading…
Reference in New Issue