Commit Graph

1216 Commits

Author SHA1 Message Date
Piotr Esden-Tempski 39fa9e4c58 Stile fixes run, 80 char boundry. 2013-06-12 21:07:35 -07:00
Piotr Esden-Tempski 34de1e776e Changed to use stdint types. 2013-06-12 19:11:22 -07:00
Piotr Esden-Tempski 7df63fcae0 First coarse run to fix coding style in locm3.
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.
2013-06-12 18:22:56 -07:00
Piotr Esden-Tempski 48e0f3326b Added linux kernel checkpatch.pl script and stylecheck target.
To make it easier on everyone to keep a uniform coding style throughout
the project we will be using this target to verify our code for
complience.

Currently a lot of files in the project don't fully follow the coding
style. We need to reach that spot over time though. :)
2013-06-11 18:10:29 -07:00
Piotr Esden-Tempski 230c673a3e Added reference about locm3 submoduling and IRC channel. 2013-06-10 17:49:12 -07:00
Felix Ruess 0bf8324c91 stm32f1: add timer.o to objects for timer_ic_set_polarity 2013-06-04 18:44:19 +02:00
Karl Palsson a5966093e6 [stm32l1] Never write illegal values to voltage range selection
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.
2013-06-03 19:38:37 +00:00
Karl Palsson 8cfaef7fb6 [stm32l1] Don't use an intermediate clock in setup
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.
2013-06-03 19:38:37 +00:00
Piotr Esden-Tempski 13fae83451 Added new sam generated header directory to ignore list. 2013-06-02 18:36:57 -07:00
Ben Gamari 80824ea22c stm32f1/adc: Kill redundant ADC_SMPR macros 2013-06-02 18:34:12 -07:00
Ben Gamari e8182a39ab stm32f4/adc: Kill redundant ADC_SMPR macros 2013-06-02 18:32:54 -07:00
Ben Gamari d90ec98f52 stm32: Add missing exti_get_flag_status 2013-06-02 18:32:40 -07:00
Ben Gamari e5a3a582fd stm32/f4/adc: Fix SMPR_SMP values
These were brought over (incorrectly) from the F1.
2013-06-02 18:32:31 -07:00
Piotr Esden-Tempski 99a909dba0 Fixed "function declaration isn't a prototype" warning introduced by the last patch. 2013-06-02 18:25:52 -07:00
Mikhail Avkhimenia 15e35d5bc1 [stm32] Added basic support for hash processor
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.
2013-06-02 18:23:49 -07:00
Ken Sarkies f5c9bdfe61 Changes to doxygen markup to solve a few problems that upset
doxygen, and to correct minor errors.
2013-06-02 18:17:49 -07:00
Karl Palsson bad5580492 [make] Use less shell variables
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.
2013-06-02 18:11:49 -07:00
Paul Fleischer b876b72b39 lm4f: Add control over UART FIFOs 2013-06-02 18:05:49 -07:00
Gareth McMullin 662a2cb8fa sam: Add convenience function for clock setup using internal 4MHz. 2013-06-02 18:01:38 -07:00
Gareth McMullin ce3e3dc39b Split sam3x/sam3n support. 2013-06-02 18:01:38 -07:00
Alexandru Gagniuc 4535a4c9b6 lm4f: Implement GPIO interrupt control
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>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc f53839f33f lm4f: Implement GPIO configuration and control
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>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc a3784aa54f lm4f: Add GPIO register definitions
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc 991fbd01be lm4f: Add all GPIO ports to memorymap.h
The base addresses for GPIO ports J through Q were missing. Add them.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc de55bbc46e lm4f: "Pretty-ize" the look of Doxygen comments in gpio.c/.h
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>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc 4c45702d2d lm4f: Switch GPIOs to using AHB bus ***WARNING***
The AHB bus allows faster control of GPIO pins versus the older APB bus.
The GPIO ports A through H default on the APB bus. Change the GPIOx
defines in gpio.h to use the base address of the AHB bus.

There's another reason to use the AHB bus: ports K tand highercan only be
accessed via the AHB bus.

***WARNING***
To work, GPIO acces to the AHB bus must be explictly enabled via the
GPIOHBCTL register. Without any additional change, this patch will break
any code using the older APB bus. If the GPIOHBCTL is not properly
modified, any acces to the GPIO register will cause a hard fault.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-06-02 16:16:46 -07:00
Alexandru Gagniuc 2184eb2b13 lm4f: Improve read/write endpoint performance
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>
2013-05-20 17:52:33 -05:00
Alexandru Gagniuc 9d46103ced lm4f: Add functions for controlling USB interrupts
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>
2013-05-16 01:36:17 -05:00
Alexandru Gagniuc ad048f7d5a lm4f: Add doxygen documentation for the USB driver
Add minimal documentation for the USB driver. The internal functions and
structs are excluded.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-16 01:36:10 -05:00
Alexandru Gagniuc 2fda5282ab lm4f: Implement a basic USB driver
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>
2013-05-15 18:17:48 -05:00
Alexandru Gagniuc df5bc49245 lm4f: Add USB register definitions
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-15 18:17:06 -05:00
Fergus Noble 4ad30d56b4 Add higher level flash_program function for f2/f4 to write a buffer into flash. 2013-05-10 18:53:19 -07:00
Fergus Noble 410be2a39a **** WARNING **** This change may break your code!!!
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.
2013-05-10 18:51:01 -07:00
Fergus Noble b039504494 Moving stm32 f2/f4 flash code into the common area. 2013-05-10 18:34:55 -07:00
Fergus Noble 4d15da995e Adding basic support for v7m sync primatives and mutex convenience functions. 2013-05-10 14:30:17 -07:00
Alexandru Gagniuc 5507e14cd4 lm4f: Implement DMA enable/disable functions for the UART
Add basic rx/tx_dma_enable/disable functionality.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-10 14:20:12 -07:00
Alexandru Gagniuc a8fc67d569 lm4f: Implement UART interrupt control
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>
2013-05-10 14:20:11 -07:00
Alexandru Gagniuc 8112861b60 lm4f: Add basic UART implementation
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>
2013-05-10 14:20:11 -07:00
Alexandru Gagniuc a105bcaa83 lm4f: Add UART "convenience" macros
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-10 14:20:11 -07:00
Alexandru Gagniuc 3573bf170a lm4f: Add UART register definitions
Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-10 14:20:11 -07:00
Piotr Esden-Tempski ce42531283 Added *.tag files and the new generated sam3x include subdirectory to gitignores. 2013-05-10 14:13:30 -07:00
Alexandru Gagniuc 7b9e8ba2e4 lm4f-doc: Sanitize doxygen structure in rcc.h
By somo copypaste error, the doxygen group rcc_defines was defined twice.
Don't do that. Keep Ken's doxygen structure and drop the old one.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-05-10 14:11:24 -07:00
Michael Aherne b9a6bbe56e Minor fix to compile functions in rtc.h 2013-05-10 14:09:06 -07:00
Gareth McMullin 05fb6fa19f sam3x: Add usart funciton to enable rx interrupt. 2013-05-10 14:01:17 -07:00
Gareth McMullin e2eadfddb8 sam3x: Add convenince functions for setting clocks and usart baudrate. 2013-05-10 14:01:17 -07:00
Gareth McMullin 8265953b35 sam3x: Add missing return types to pwm functions. 2013-05-10 14:01:16 -07:00
Gareth McMullin c9cd2d9ab1 sam3x: Correct pmc_xtal_enable to use startup time parameter. 2013-05-10 14:01:16 -07:00
Gareth McMullin 060839ee4c sam3x: Add some pwm convenience funcitons. 2013-05-10 14:01:16 -07:00
Gareth McMullin 614e26a3b1 sam3x: Add gpio_init convenience function. 2013-05-10 14:01:16 -07:00
Gareth McMullin f311966f09 sam3x: Add USART registers and come convenience functions. 2013-05-10 14:01:16 -07:00