-
Notifications
You must be signed in to change notification settings - Fork 4
Non intrusive changes to get some SAMD board working. #1
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
base: master
Are you sure you want to change the base?
Conversation
Some imrpovements in SAM Lazarus lpi files.
|
Added some display abstraction. |
Register r4 is sometimes used for $self, so avoid using it in the pure assembler routines.
| </SyntaxOptions> | ||
| </Parsing> | ||
| <CodeGeneration> | ||
| <HeapSize Value="8192"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you removed Heap/StackSize Values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anything particular.
My normal practice is to try to get things running with as little extra settings as possible.
So, its just a way for me to check if things are running without these extra settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am too lazy to look this up in details atm but I guess your code will sooner or later crash and burn when those are not properly set. But it may be that some defaults are applied when nothing is set, as said, too lazy to look this up atm.
| </CodeGeneration> | ||
| <Linking> | ||
| <Debugging> | ||
| <GenerateDebugInfo Value="False"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, any specific reason for this? Having Debug Info will not change the size of the deployed code, so why turn DebugInfo off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not anything particular.
My normal practice is to try to get things running with as little extra settings as possible.
| <Version Value="11"/> | ||
| <Target> | ||
| <Filename Value="Blinky"/> | ||
| <Filename Value="bin/$(TargetCPU)-$(TargetOS)/samc21/$NameOnly($(ProjFile))"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you did this because you had issues with build.
There are two problems here:
a) As we heavily use defines it is still unsave to do a simple build, better do a rebuild all from time to time
b) If we stay with this we will need a generic way to define the name of the 'samc21' directory because I also need to define the path to the executable for Debugging (Ozone)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No build issues.
I always use a single lpi for multiple targets.
And use "Compile many Modes" to generate all binaries at once.
And use the paths settings to split libraries and binaries for easy comparison.
| @@ -0,0 +1,116 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments here as for the other lpi file, or did I overlook something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct: you did not overlook anything ... ;-)
| @@ -27,7 +27,7 @@ | |||
| {$if defined(SAMD10XMINI)} | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| TArduinoPin = record | ||
| const | ||
| None=-1; | ||
| D13= TNativePin.PA14; // just for blinky to work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way to do things. Better define a const LED (and LED0) with value TNativePin.PA14.
You should not 'kill' the ArduinoPins Definition for the sake of making Blinky run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fully agreed.
But the current Blinky used this Arduino-pin, and the board itself has no Arduino pins.
Please correct me if I am wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look here:
http://www.microchip.com/DevelopmentTools/ProductDetails/atardadpt-xpro
The shield is a little difficult to find when you do not know what to search for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha !
Did not know of this adapter-board !
Nice addition.
Surely, the Arduino pin-definitions must be included.
Source/MBF.SAMCD.SystemCore.pas
Outdated
| @@ -232,7 +232,9 @@ procedure WaitSYSCTRL; | |||
| SYSCTRL_DFLLCTRL_QLDIS; // 1 = Disable quick lock. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| @@ -0,0 +1,377 @@ | |||
| program MBED; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will not yet add this sample as it is looking way too complicated and often does not use concepts of MBF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is ok for me.
Its just a proof of concept.
If all concepts of MBF are clear and stable, this example can easily be adapted.
| @@ -0,0 +1,152 @@ | |||
| program OLED1; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will not merge this example in this form as it is not following mbf concepts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
That is ok for me.
Its just a proof of concept.
|
|
||
| const | ||
| {$if defined(has_samd20_xplained_pro) or defined(has_samd21_xplained_pro) or defined(has_samc21_xplained_pro)} | ||
| PinLED = LED0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of those definitions will (hopefully) get opsolete when SPI Code is completely implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope so too !
| TurnedOn:boolean; | ||
| i:byte; | ||
|
|
||
| procedure ToggleLed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is toggling an LED part of this demo code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me (and others), to indicate that the board is still alive and kicking !!
| GPIO.PinValue[PinLED] := 1; | ||
|
|
||
| Display.InvertScr(false); | ||
| Display.ClrScr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ClrScr and not ClearScreen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ClearScreen does not do anything (yet).
ClrScr does clear the screenbuffer, without updating the screen.
Should/must be improved !
| Display.Pixel[i,0]:=1; | ||
| Display.Present; | ||
| end; | ||
| for i:=0 to (ScreenSize128x32x1.Height-1) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why make this so complicated? ScreenInfo is a public property of (my) TCustomDisplay, better use this instead...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure !!! :-)
My mistake.
| @@ -36,7 +36,6 @@ procedure ClearBit(var Value: longword; const Index: Byte); | |||
| lsl r3, r1 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| @@ -0,0 +1,704 @@ | |||
| unit MBF.Displays.OLED1Xplained; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file will need reworking, it uses up too much memory by defining fonts and some screenbuffer content.
Please check my ssd1963 code, fonts are provided via extra units.
I have also written a (very crude) windows GUI that allows you to convert ttf fonts to pascal fonts.
Please check this site:
https://int10h.org/oldschool-pc-fonts/fontlist/
They have some nice ttf fonts that can be converted to perfectly looking pascal fonts with my tool.
I only need to extend the tool to now also create fonts in format specific to those OLED Displays
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, for sure.
Its just a (working) demo.
| Result := Pointer(FScreenBuffer + (Cardinal(Index) shr 3) * Cardinal(FScreenSize.X)); | ||
| end; | ||
|
|
||
| procedure TDisplay.ClrScr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ClrScr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
Not enough abstraction yet. Need to be changed.
| @@ -0,0 +1,704 @@ | |||
| unit MBF.Displays.OLED1Xplained; | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, as written in E-Mail we should think about two kinds of Display Units, one with Framebuffer, one without...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A screenbuffer could just be a single pointer.
That is assigned or not.
And used accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One problem of pxl for microcontrollers was that it is very well designed, which caused huge impacts on performance and filesize.
When we allow both framebuffer/NoFramebuffer in one object my fear is that we increase the codesize a lot by always having framebuffer/non-framebuffer code in one procedure/function.
Whith often only 8 or 16k flash this hurts, when you have seperate implementations the design is compromised but you may be able to run the code on devices with lower specs.
I am not sure if I have written that before, I am dtruggeling with myself here as there is a rich choice of boards with plenty of ram/flash but usually Jeppe and I got requests to create header files for boards with crazy low ram/flash footprint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, you are right.
I will think about it.
Perhaps, a framebuffer object can be injected into a display object abstraction. Too late now. Will think with fresh brains tomorrow !
| {$ifdef samc} | ||
| while (Self.SYNCBUSY>0) do begin end; // Wait for synchronization | ||
| {$endif} | ||
| end; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should throw an error when no definition matches, this makes extending mbf a lot easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure !!
| {$ifdef has_adc0}ADC0_BASE : SetBit(MCLK.APBCMASK,MCLK_APBCMASK_ADC0_Pos);{$endif} | ||
| {$ifdef has_adc0}ADC1_BASE : SetBit(MCLK.APBCMASK,MCLK_APBCMASK_ADC1_Pos);{$endif} | ||
| end; | ||
| {$endif} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, create a compliler error when no definition matches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure !!
|
|
||
| const | ||
| {$ifdef samd10} | ||
| TADCPinsMap : array[TADCPin] of TPinIdentifier=( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to use definitions as done in my SPI code (For example mbf.stm32f4.spi TSPIMOSIPins
The advantage is that you get a choice of all available analog pins in Lazarus which makes coding a lot easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into it !
| {$endif} | ||
| {$endif} | ||
|
|
||
| {$ifdef has_samd20_xplained_pro} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| result:=GetBit(FSerCom.PSerComRegisters^.SPI.INTFLAG,SERCOM_SPI_INTFLAG_RXC_Pos); | ||
| end; | ||
|
|
||
| procedure TSPI_Registers.WriteSingle(aData:word); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we will have to clean up Procedures for Write on SPI, I think a good approach is to use typesafe implementations and a generic pointer implementation as a fallback. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agreed.
| TicksPerMillisecond := GetSysTickClockFrequency div 1000; | ||
|
|
||
| {$if defined(CPUARM)} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way that this can get moved to SystemCore.SAMCD as it is SAMCD specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. I do not see any problems with that.
No description provided.