Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renew lgtx8p.h and lgtx8e.h with Arduino style register definitions. #79

Merged
merged 14 commits into from
Feb 22, 2021
Merged

Renew lgtx8p.h and lgtx8e.h with Arduino style register definitions. #79

merged 14 commits into from
Feb 22, 2021

Conversation

LaZsolt
Copy link
Collaborator

@LaZsolt LaZsolt commented Feb 14, 2021

(*((volatile unsigned char *) address )) replaced to _SFR_MEM8( address ) or _SFR_IO8( address )
and replacement of the missing 16 bit registers definitions: _SFR_MEM16( address ) or _SFR_IO16( address )
according to #57 (comment)

@dbuezas
Copy link
Owner

dbuezas commented Feb 14, 2021

Fantastic!
Please confirm you tested it by running code that uses some registers and I'll merge asap

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Feb 14, 2021

Not tested yet, but I read back every modification many times carefully. I ask others to help testing this two files.

@dbuezas dbuezas marked this pull request as draft February 14, 2021 20:15
@dbuezas
Copy link
Owner

dbuezas commented Feb 14, 2021

Marked as draft, you can mark it as "not draft" when you've smoke tested it and want me to merge.
This looks so much better than before! 💯

@dbuezas
Copy link
Owner

dbuezas commented Feb 14, 2021

By the way, related to register definitions, I use vscode and it is nice to get datasheet bits when you hover a register.
What do you think about this ?
Screen Shot 2021-02-14 at 21 21 03

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Feb 15, 2021

@dbuezas
I think it is a lot of work to copy all resisters bits explanations from the databook to this file. But at the end it will be look nice.

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Feb 15, 2021

Anyway, I have only one big project, based on LGT, which not using LGT's extra registers of related to timers. So I could test if the new files are free of compiler errors.

@dbuezas
Copy link
Owner

dbuezas commented Feb 17, 2021

That should be enough for now, worse case scenario some are not fully functional, which was already the case before.

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Feb 20, 2021

Tested with this program:

/* Timer3 overflow interrupt example for LGT8F328P microcontroller */

// LED_BUILTIN = D13

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);

// initialize Timer3
  noInterrupts();             // disable all interrupts
  TCCR3A = 0;
  TCCR3B = 0;
  TCCR3C = 0;
  TCCR3D = 0;

  TCNT3 = 49911;              // preload timer 65536-16MHz/1024/2Hz
  TCCR3B |= (1 << CS32) | (1 << CS30); // 1024 prescaler
  TIMSK3 |= (1 << TOIE3);     // enable timer overflow interrupt
  interrupts();               // enable all interrupts
}

ISR(TIMER3_vect) // interrupt service routine that wraps a user defined function supplied by attachInterrupt
{
  if (TIFR3 & (1 << TOIE3)) { // Examine which event happened
     TIFR3 = (1 << TOIE3);    // Clear Timer3 interrupt flag register by setting appropriate bit.
     TCNT3 = 49911;           // preload timer
     fastioToggle(D13);       // LED on D12 pin when using red Wemos XI TTGO board
  }
}

void loop() {
// nothing
}

@dbuezas dbuezas marked this pull request as ready for review February 22, 2021 19:38
@dbuezas
Copy link
Owner

dbuezas commented Feb 22, 2021

Fantastic work @LaZsolt !
Merging now

@dbuezas dbuezas merged commit b165873 into dbuezas:master Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants