We should not add compiler extensions, it is not our job. We are not a
selfcontained project as kernel is so we should not introduce things
like this.
If we need to add some abstraction for this in the future to support
compilers doing these things differently then we will do that the same
way we dealt with the depricated attribute.
In places where we were defining memory mapped peripheral buffers we
were using directly a cast to "volatile int_type *". For consistency we
should use dereferenced accessor like: &MMIO32(address)
Added --terse and --mailback options to the make stylecheck target. It
also does continue even if it enounters a possible error.
We decided on two exceptions from the linux kernel coding standard:
- Empty wait while loops may end with ; on the same line.
- All blocks after while, if, for have to be in brackets even if they
only contain one statement. Otherwise it is easy to introduce an
error.
Checkpatch needs to be adapted to reflect those changes.
According to the reference manual, you are _forbidden_ from writing 00 to the
VOS[1:0] bits in PWR_CR. Writing a 00 is automatically turned into range 2,
or, 10. Attempting to then |= the bits for range 1 (01) results in the final
result of choosing voltage range 3 (11). This has fairly catastrophic effects
if you then attempt to switch to PLL clock at 32Mhz.
Oddly, the existing code was working fine on STM32L151C6 revision W, but
failing with revision V silicon. Regardless, the existing code was wrong and
not following the reference manual.
Further, attempting to change any power voltage range settings without the RCC
enabled will have no effect, so all the higher level helper routines
have added peripheral enable lines before attempting to set the range.
This switch to HSI was an attempt to run the setup code faster. However,
there's no real need for this, and it just confuses things by switching first
to one clock, and then to another. Just keep running on the existing clock
until switching to the clock actually chosen by the user's arguments.
Added hash processor register definitions and main functions. Hash
processor is supported in stm32f21, stm32f41 and stm32f43 and can be
used to calculate Md5 and Sha1.
Use fixed variables for things that can't change, instead of variables
like SRCLIBDIR that was causing a shell call for every single use.
Use less functions in general and less shell expansions.
Use builtin functions like $(realpath blah) instead of $(shell
pwd)/blah In particular, this was important for me trying to build on
windows with git-shell. This should help a lot on smaller build
machines, but doesn't make a huge difference on my own.
Remove redundant clean print messages. These also cause more needless
shell expansions.
Implement an API to specifiy the interrupt trigger for GPIO pins, and
control interrupts. This completes the GPIO API.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Everything needed to set up and control the GPIO pins is implemented,
EXCEPT setting up interrupts. This is the subject of a subsequent patch.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Put the Doxygen blocks in well-formatted C comments. This looks better
and is less distracting than putting them in unformatted comments.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Modify lm4f_ep_read/write_packet() to take advantage of 32-bit and 16-bit
accesses to the USB FIFO, as opposed to using only 8-bit accesses. This
change increases endpoint performance in a number of configurations.
On the host side, we use usb_bulk_bench to test
https://github.com/mrnuke/usb_bulk_bench
With the following invocations:
usb_bulk_bench -d c03e:b007 -a -t 64 -q 32 -e [ep] [-I/-O]
On the device side, we use the usb_bulk_dev example:
https://github.com/mrnuke/libopencm3-examples/tree/stellaris
The example is in: examples/lm4f/stellaris-ek-lm4f120xl/usb_bulk_dev
(This example will be available in libopencm3-examples in the near future)
The endpoints configuration is the following:
* EP1 OUT - interrupt driven RX endpoint
* EP2 IN - interrupt driven TX endpoint
* EP3 OUT - polled RX endpoint
* EP4 IN - polled TX endpoint
* EP5 OUT - polled RX endpoint with unaligned buffer
* EP6 IN - polled TX endpoint with unaligned buffer
We test the speed in each configuration, using different system clock
frequencies. We run the tests once without the patch applied, and once with
the patch applied. The results are given below:
Before patch (numbers in KiB/s):
freq: 80 MHz 57 MHz 40 MHz 30 MHz 20 MHz 16 MHz
EP1 562 562 562 562 562 550
EP2 936 872 812 812 687 625
EP3 1062 890 700 600 562 562
EP4 900 812 812 750 625 562
EP5 1062 890 700 600 562 562
EP6 930 812 812 750 625 562
With patch (numbers in KiB/s):
freq: 80 MHz 57 MHz 40 MHz 30 MHz 20 MHz 16 MHz
EP1 1062 1062 1062 690 562 562
EP2 1125 936 936 936 870 812
EP3 1062 960 750 750 562 562
EP4 936 936 870 870 770 700
EP5 1062 900 700 630 562 562
EP6 930 930 870 870 740 650
Percent change in speed (*):
freq: 80 MHz 57 MHz 40 MHz 30 MHz 20 MHz 16 MHz
EP1 89.0 89.0 89.0 22.8 0.0 2.2
EP2 20.2 7.3 15.3 15.3 26.6 29.9
EP3 0.0 7.9 7.1 25.0 0.0 0.0
EP4 4.0 15.3 7.1 16.0 23.2 24.6
EP5 0.0 1.1 0.0 5.0 0.0 0.0
EP6 0.0 14.5 7.1 16.0 18.4 15.7
(*) Numbers given as percent change relative to speed before applying this
patch.
We see throughput increases across the board.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Add functions to enable and disable USB interrupts, and document how to
use these functions to run usbd_poll() from the usb ISR.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Implement a basic driver for the LM4F USB controller. The driver is in a
basic form. DMA is not yet implemented. Double-buffering is supported by
the hardware, but is not yet implemented
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Change flash_erase_sector (f2/f4) to take numerical sector argument.
As opposed to using one of the defines in the header, this is more convenient when programatically deciding which sectors to erase.
Add a complete API for controlling the UART interrupts.
Doxygen documentation with inline code examples is also provided in this patch.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Add basic functionality needed to setup the UART and send/recieve data.
Interrupts, DMA, and more advanced features are not implemented in this patch.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
rcc_set_pll_divisor() would take the number we wanted to divide the 400MHz
clock and put it directly in the RCC2 register. This caused the clock to always
be one speed tier slower than expected. The value of the divisor must be
decremented by 1, so a divisor of 5 will be written as 4 in the RCC2.
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
f1/timer.
Added timer_ic_set_polarity to timer_common_f24 with
the enum tim_ic_pol now including trigger on both edges.
Changed timer_slave_set_polarity to use enum tim_et_pol
rather than tim_ic_pol.
In response to suggestion of stinkydiver73 on 24 March that
timers in all families have an option for triggers on both
edges, except F1.
Current way of having a globally, but weakly defined static buffer has
several shortcomings:
- It forces user to have a certain "magic" byte array variable if
they want to have a control buffer of different size.
- Having a globally defined static array and a separate function to
tell USB core about its size is error prone.
- Its inner workings are not easily understandable form cursory look
at API and one needs to go and look at the implementation code to
connect all the pieces into a solid picture of how it works
This commit adds two parameters to 'usbd_init' call that allow user to
specify the pointer to the area of memory and a size of that memory
which would be used by the USB core to store the data received during
DATA stage of control requests. This approach, while further
complicating the prototype of 'usbd_init', provides user with more
flexibility allowing for any custom area of memory of any size to be
used as control buffer. It also forces user to provide both address
and memory size at the same time thus avoiding the possibility of user
redefining 'usbd_control_buffer', but not calling
'usbd_set_control_buffer_size' after that.
This also report bug fixes about data alignment and bss storage to EFM32 &
LM3S targets.
Note: removed chrysn copyright statement as the file is a verbatim copy of
previous files.