Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
036a156f
Commit
036a156f
authored
15 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Slight improvements to the reliability of the software UART in the XPLAINBridge project.
parent
931ca42a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
LUFA/Drivers/USB/Class/Device/CDC.c
+1
-1
1 addition, 1 deletion
LUFA/Drivers/USB/Class/Device/CDC.c
Projects/XPLAINBridge/Lib/SoftUART.c
+20
-23
20 additions, 23 deletions
Projects/XPLAINBridge/Lib/SoftUART.c
Projects/XPLAINBridge/XPLAINBridge.c
+3
-1
3 additions, 1 deletion
Projects/XPLAINBridge/XPLAINBridge.c
with
24 additions
and
25 deletions
LUFA/Drivers/USB/Class/Device/CDC.c
+
1
−
1
View file @
036a156f
This diff is collapsed.
Click to expand it.
Projects/XPLAINBridge/Lib/SoftUART.c
+
20
−
23
View file @
036a156f
...
@@ -63,41 +63,38 @@ void SoftUART_Init(void)
...
@@ -63,41 +63,38 @@ void SoftUART_Init(void)
EICRA
=
(
1
<<
ISC01
);
EICRA
=
(
1
<<
ISC01
);
EIMSK
=
(
1
<<
INT0
);
EIMSK
=
(
1
<<
INT0
);
/* Ensure that when the timer is enabled the transmission ISR runs immediately */
/* Start software UART transmission and reception timers */
OCR1B
=
TCNT1
+
1
;
TIMSK3
=
(
1
<<
OCIE3A
);
TCCR3B
=
(
1
<<
CS30
);
/* Start timer 1 with transmission channel force-enabled so that it will immediatly fire */
TCCR1C
=
(
1
<<
FOC1B
);
TIMSK1
=
(
1
<<
OCIE1B
);
TCCR1B
=
(
1
<<
CS10
);
TCCR1B
=
(
1
<<
CS10
);
}
}
/** ISR to detect the start of a bit being sent to the software UART. */
/** ISR to detect the start of a bit being sent to the software UART. */
ISR
(
INT0_vect
)
ISR
(
INT0_vect
,
ISR_BLOCK
)
{
{
/* Set reception channel to fire 1.5 bits past the beginning of the start bit */
/* Set reception channel to fire 1.5 bits past the beginning of the start bit */
OCR1A
=
TCNT1
+
(
(
BIT_TIME
*
3
)
/
2
);
OCR1A
=
TCNT1
+
(
BIT_TIME
+
(
BIT_TIME
/
2
)
)
;
/* Clear the received data temporary variable, reset the current received bit position mask */
/* Clear the received data temporary variable, reset the current received bit position mask */
RX_Data
=
0
;
RX_Data
=
0
;
RX_BitMask
=
(
1
<<
0
);
RX_BitMask
=
(
1
<<
0
);
/* Clear reception channel ISR flag in case it is pending */
TIFR1
=
(
1
<<
OCF1A
);
/* Check that the start bit is still low to prevent noise from triggering a reception */
/* Check that the start bit is still low to prevent noise from triggering a reception */
if
(
!
(
SRXPIN
&
(
1
<<
SRX
)))
if
(
!
(
SRXPIN
&
(
1
<<
SRX
)))
{
{
/*
Still low, enable both send and receive channels
*/
/*
Clear reception channel ISR flag in case it is pending
*/
TI
MSK
1
=
(
1
<<
OC
IE1A
)
|
(
1
<<
OCIE1B
);
TI
FR
1
=
(
1
<<
OC
F1A
);
/* Clear the start bit detection ISR flag if it is pending */
/* Still low, enable bit receive ISR */
TIMSK1
=
(
1
<<
OCIE1A
);
/* Clear the start bit detection ISR flag */
EIMSK
&=
~
(
1
<<
INT0
);
EIMSK
&=
~
(
1
<<
INT0
);
}
}
}
}
/** ISR to manage the reception of bits to the software UART. */
/** ISR to manage the reception of bits to the software UART. */
ISR
(
TIMER1_COMPA_vect
)
ISR
(
TIMER1_COMPA_vect
,
ISR_BLOCK
)
{
{
/* Move the reception ISR compare position one bit ahead */
/* Move the reception ISR compare position one bit ahead */
OCR1A
+=
BIT_TIME
;
OCR1A
+=
BIT_TIME
;
...
@@ -118,17 +115,17 @@ ISR(TIMER1_COMPA_vect)
...
@@ -118,17 +115,17 @@ ISR(TIMER1_COMPA_vect)
RingBuffer_Insert
(
&
UARTtoUSB_Buffer
,
RX_Data
);
RingBuffer_Insert
(
&
UARTtoUSB_Buffer
,
RX_Data
);
/* Disable the reception ISR as all data has now been received, re-enable start bit detection ISR */
/* Disable the reception ISR as all data has now been received, re-enable start bit detection ISR */
TIMSK1
=
(
1
<<
OCIE1B
);
TIMSK1
=
0
;
EIMSK
|=
(
1
<<
INT0
);
EIFR
=
(
1
<<
INTF0
);
EIFR
=
(
1
<<
INTF0
);
EIMSK
=
(
1
<<
INT0
);
}
}
}
}
/** ISR to manage the transmission of bits via the software UART. */
/** ISR to manage the transmission of bits via the software UART. */
ISR
(
TIMER
1
_COMP
B
_vect
)
ISR
(
TIMER
3
_COMP
A
_vect
,
ISR_NOBLOCK
)
{
{
/* Move the transmission ISR compare position one bit ahead */
/* Move the transmission ISR compare position one bit ahead */
OCR
1B
+=
BIT_TIME
;
OCR
3A
+=
BIT_TIME
;
/* Check if transmission has finished */
/* Check if transmission has finished */
if
(
TX_BitsRemaining
)
if
(
TX_BitsRemaining
)
...
...
This diff is collapsed.
Click to expand it.
Projects/XPLAINBridge/XPLAINBridge.c
+
3
−
1
View file @
036a156f
...
@@ -166,6 +166,8 @@ void SetupHardware(void)
...
@@ -166,6 +166,8 @@ void SetupHardware(void)
/* Re-enable JTAG debugging */
/* Re-enable JTAG debugging */
MCUCR
&=
~
(
1
<<
JTD
);
MCUCR
&=
~
(
1
<<
JTD
);
MCUCR
&=
~
(
1
<<
JTD
);
MCUCR
&=
~
(
1
<<
JTD
);
CurrentFirmwareMode
=
MODE_USART_BRIDGE
;
// TEMP
}
}
/** Event handler for the library USB Configuration Changed event. */
/** Event handler for the library USB Configuration Changed event. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment