File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -193,19 +193,23 @@ export class AVRUSART {
193193 return this . rxBusyValue ;
194194 }
195195
196- writeByte ( value : number ) {
197- const { cpu, config } = this ;
198- if ( this . rxBusyValue || ! ( cpu . data [ config . UCSRB ] & UCSRB_RXEN ) ) {
196+ writeByte ( value : number , immediate = false ) {
197+ const { cpu } = this ;
198+ if ( this . rxBusyValue || ! this . rxEnable ) {
199199 return false ;
200200 }
201- this . rxBusyValue = true ;
202- cpu . addClockEvent ( ( ) => {
201+ if ( immediate ) {
203202 this . rxByte = value ;
204- this . rxBusyValue = false ;
205203 cpu . setInterruptFlag ( this . RXC ) ;
206204 this . onRxComplete ?.( ) ;
207- } , this . cyclesPerChar ) ;
208- return true ;
205+ } else {
206+ this . rxBusyValue = true ;
207+ cpu . addClockEvent ( ( ) => {
208+ this . rxBusyValue = false ;
209+ this . writeByte ( value , true ) ;
210+ } , this . cyclesPerChar ) ;
211+ return true ;
212+ }
209213 }
210214
211215 private get cyclesPerChar ( ) {
You can’t perform that action at this time.
0 commit comments