1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00

1530 Commits

Author SHA1 Message Date
James Snyder
06dd9a295d Fix missing element in external ints for stm32
- stm32, stm32f2 & stm32f4 were missing EXTI_Line11 in external
  interrupts source list, causing out of bounds & interrupt source
  identification
2014-04-15 10:42:25 -05:00
James Snyder
9f9577a321 Don't optimize numbers for compressed romfs on integer builds
- luasrcdiet uses 'e' notation which doesn't work in integer builds
2014-04-14 15:14:19 -05:00
James Snyder
c67dd89237 Merge pull request #49 from smartavionics/mb-stm32f4-timer-mods
Mb stm32f4 timer mods
2014-04-06 13:51:37 -05:00
Mark Burton
55dd1f908c Keep the timer running when stopping timer generated cyclic interrupts.
For some reason (unknown to me) platform_s_timer_set_match_int() was clearing
the timer's CR1 and CR2 regs when the interrupts are to be stopped. This
had the effect of stopping the timer completely so a delay() on that timer
would hang forever. Now the timer keeps running and can be used normally
after the interrupts have been stopped.
2014-04-06 12:13:33 +01:00
Mark Burton
d55c74be67 In platform_s_timer_delay() don't assume timer reload value is all ones.
If the timer has been used to clock ADC or PWM or to generate interrupts
the reload value is unlikely to be all ones. The reload value will be
all ones if the timer has just been used as an elua timer.

So, when the timer wraps use the real reload value which is in ARR rather
than assuming it is 0xFFFF or 0xFFFFFFFF.
2014-04-06 12:09:21 +01:00
Mark Burton
324b0e7db8 Fix platform_s_timer_delay() so it doesn't hang when specified delay is too large.
Previously, if the specified delay resulted in a final value that
was wider than the timer width, the code would loop forever because the
timer counter would never reach the value of final.

Now, it checks to see if the timer has wrapped and, if so, reduces the value
of final by the timer's max count value.

An added benefit is that now all timers can delay for up to the maximum
delay handled by the target whereas previously the maximum delay was limited
by the width of the counter.
2014-04-06 09:21:59 +01:00
Mark Burton
d37f0e3331 Add support for 32 bit timers TIM2 and TIM5 (id 1 and 4).
These timers now handle 32 bit counts & delays.
2014-04-06 09:14:10 +01:00
Bogdan Marinescu
f20e817ee8 Merge pull request #47 from smartavionics/stm32f4-nucleo
Stm32f4 nucleo
2014-03-25 20:21:01 +00:00
Bogdan Marinescu
943189bb26 Merge pull request #45 from ecdr/MiscUpdates
Misc updates
2014-03-25 20:20:35 +00:00
Bogdan Marinescu
c0e9b8bf97 Merge pull request #41 from smartavionics/mb-stm32f4-cpu-additions
Add getclksfreq(), wfe(), wfi(), rnd.setup() and rnd.read() functions.
2014-03-25 20:18:28 +00:00
Mark Burton
baa5d9c76d Rework configuration of STM32F4 HSI clock.
Now, to use the HSI clock, specify an internal clock frequency in the
"clocks" config section, like this...

clocks = { internal = 16000000, cpu = 84000000 }

Don't specify an external frequency as well as the internal frequency.
2014-03-20 18:31:48 +00:00
Mark Burton
e2121e72fa Now determines the required flash latency from the system clock frequency.
This assumes that the MCU supply voltage is at least 2.7V.
2014-03-20 18:18:21 +00:00
Mark Burton
1611fab94b Can't use HSE clock on the Nucleo board as it's not populated.
The board as supplied does not provide any external clock to the F4.
It could supply an 8MHz clock from the STLINK part but, by default, it
isn't configured to do that.

So just use the HSI instead of the HSE - it won't be good for USB or fast
CAN bit rates but should be fine for bit banging, etc.
2014-03-20 16:46:02 +00:00
Mark Burton
7b790be60d Reduce the flash latency to 2WS as that is sufficient for the 84MHz clock. 2014-03-20 16:38:32 +00:00
ecdr
593044af24 LM3S - platform.c - remove duplicate include 2014-03-19 21:48:59 -08:00
ecdr
025dabfc6a LM3S - platform.c - MAP_ - Use ROM versions of library if available 2014-03-19 21:48:58 -08:00
ecdr
02fa7beac4 LM3S - platform_int - use platform_pio_get_num_pins rather than assuming 8 pins per port 2014-03-19 21:48:58 -08:00
ecdr
307de046e2 LM3S - startup_gcc - use console UART, rather than assuming UART0 2014-03-19 21:48:57 -08:00
ecdr
cb849d0d46 LM3S - startup_gcc.c - human readable error messages for default ISRs
also, use ROM versions of UARTCharPut, if available
2014-03-19 21:48:57 -08:00
ecdr
7dc3b36b52 platform.h - note unused constants
PLATFORM_SPI_TOTAL, PLATFORM_UART_TOTAL, PLATFORM_PWM_TOTAL

TODO: Figure out purpose, or remove them
2014-03-19 21:48:56 -08:00
ecdr
1019acf756 elua i2c module - fix comment 2014-03-19 21:48:56 -08:00
ecdr
dd5053fb29 eLua - comments - include return from functions in can, i2c 2014-03-19 21:48:55 -08:00
ecdr
c4493d48a4 DOC - CAN - fix typo 2014-03-19 21:48:55 -08:00
Bogdan Marinescu
ea93180b5b Merge pull request #44 from smartavionics/stm32f4-nucleo
Ported to STM32F401 Nucleo board.
2014-03-19 12:46:37 +00:00
Mark Burton
8c6757e856 Ported to STM32F401 Nucleo board.
The Nucleo boards are like the Discovery boards in that they come with an
attached STLINK-V2 programmer. The MCU's UART2 is routed through the
programmer's USB connection and it appears as a VCP device on the host.

So far, this has only been tested to the extent that the elua shell and
lua prompt appear to be functioning as expected.
2014-03-19 12:10:45 +00:00
James Snyder
044f861a90 Merge pull request #43 from smartavionics/mb-misc-mods
Fixes for a compilation problem and a race in the system timer code.
2014-02-24 19:00:40 -06:00
Mark Burton
4cfaeebe1d Add functions to read STM32F4 MCU id and unique device id.
stm32f4.cpu.read_mcu_device_id() returns a number containing the 32 bit id.

stm32f4.cpu.read_unique_device_id() returns an array of 3 numbers. The first
number contains bits 0-31, the second number contains bits 32-63 and the
last number contains bits 64-95 of the unique device id.
2014-02-24 17:30:36 +00:00
Mark Burton
aa7c774f1e Merge branch 'master' into mb-stm32f4-cpu-additions 2014-02-24 17:20:01 +00:00
Mark Burton
e9f23cc33f Reorder assignments in cmn_systimer_get() to avoid race.
Before, it was possible for the system timer counter to wrap from high to low
after its value had been read but before the value of cmn_systimer_counter
was read and so the resulting sum of those values would be too large.

By reordering the assignments, we can now detect if cmn_systimer_counter has
been advanced while reading the system timer counter value and, if so, repeat
the assignments to ensure consistent values.
2014-02-23 18:07:06 +00:00
Mark Burton
e11180bc75 For STM32, use CAN_NO_MB instead of CAN_TxStatus_NoMailBox. 2014-02-23 16:19:13 +00:00
Mark Burton
d217905667 Change stm32f4.cpu.rng.read() to return a number rather than an integer.
This ensures the result is always positive when numbers are not 32 integers.
2014-02-19 15:05:56 +00:00
James Snyder
379195945b Merge pull request #42 from smartavionics/mb-misc-mods
Change a couple of #warn directives to #warning.
2014-02-10 12:33:19 -06:00
Mark Burton
142e809699 Change a couple of #warn directives to #warning. 2014-02-10 16:30:20 +00:00
James Snyder
4456f990ff Merge pull request #39 from smartavionics/mb-misc-mods
Mb misc mods
2014-02-09 15:27:15 -06:00
James Snyder
b1361bcf2e Merge pull request #40 from smartavionics/mb-stm32f4-can-timing
Add CAN bit timing values for use with 120 MHz and 96 MHz system clocks.
2014-02-09 15:24:10 -06:00
Mark Burton
bcdd7f46d1 Add getclksfreq(), wfe(), wfi(), rnd.setup() and rnd.read() functions.
wfe() and wfi() just call the underlying ARM functions.

getclksfreq() returns a table containing these clock frequencies: SYSCLK,
HCLK, PCLK1 and PCLK2.

rnd.setup() initialises the random number generator. rnd.read() will call
this anyway if the RNG hasn't been initialised before you read from it. If
rng.read() ever returns nil to signify a problem, you can call rnd.setup()
to re-initialise the RNG.

rnd.read() returns a 32 bit random number or nil if the generator signals
an error.
2014-02-09 08:23:19 +00:00
Mark Burton
ff090e8df8 Add CAN bit timing values for use with 120 MHz and 96 MHz system clocks.
The values used produce sampling points around 65-70% which is similar
to the original set of values.

Values courtesy of http://www.bittiming.can-wiki.info/
2014-02-04 11:04:15 +00:00
Mark Burton
a9fd03053d Correct value of PLATFORM_TIMER_SYS_MAX for lua long builds.
It was being set to ( ( 1LL << 31 ) - 2 ) which only used 31 bits when 32
are available. By setting it to ( ( 1LL << 32 ) - 2 ) the range of the timer
is doubled to around 4295 seconds. Note that time values greater than
approx 2147 seconds will have the top bit (1 << 31) set and so will appear
to be negative as all numbers are considered to be signed.
2014-02-02 11:08:37 +00:00
Mark Burton
4ccaaf0e57 Avoid losing time when cmn_systimer_counter exceeds PLATFORM_TIMER_SYS_MAX.
Setting cmn_systimer_counter to zero when the systimer exceeded
PLATFORM_TIMER_SYS_MAX would cause time to jump backwards if
cmn_systimer_counter was already greater than PLATFORM_TIMER_SYS_MAX.

So now, instead of zeroing it, we subtract PLATFORM_TIMER_SYS_MAX.
2014-02-02 09:48:12 +00:00
Mark Burton
93fc647638 Avoid 64 bit divide in cmd_systimer_get(). 2014-02-02 09:42:27 +00:00
Mark Burton
5e81e42152 Now clears FIFO empty interrupt mask in DCD_WriteEmptyTxFifo() when transfer completes.
This fixes a problem whereby outputting to the USB UART when the host is
connected but the USB UART is not open would cause the interrupt
handler to be called continuously so it would consume 100% of the CPU.
2014-02-01 19:15:47 +00:00
Mark Burton
b95eea268b Avoid 64 bit mul+div in platform_timer_get_diff_us() when timer rate is 1 MHz. 2014-02-01 15:46:16 +00:00
James Snyder
b2f36c8ced Merge pull request #38 from smartavionics/mb-stm32f4-can2
Add support for the second stm32f4 CAN interface.
2014-01-27 11:54:48 -08:00
Mark Burton
c48bdf802c Add support for the second stm32f4 CAN interface.
This is copied from the stm32f2 code with some #if's added so that you can
select the MCU pins used for the CAN signals at compile time. Four configurations
are supported.

For example, the board config file can contain this:

  macros = { 'ELUA_BOARD_STM32F4_CAN_PIN_CONFIG_2' }
2014-01-27 15:17:24 +00:00
James Snyder
07ee92bd09 Merge pull request #37 from smartavionics/master
Missed from recent commit that added status return to platform_can_send() - sorry!
2014-01-27 06:56:16 -08:00
Mark Burton
324c02776d Missed from recent commit that added status return to platform_can_send() - sorry! 2014-01-27 10:39:06 +00:00
Bogdan Marinescu
0e504711c9 Merge pull request #36 from smartavionics/mb-can-send-result
Add status return to can.send() and underlying platform_can_send() functions.
2014-01-27 00:15:29 -08:00
Mark Burton
e120b9dc14 Add status return to can.send() and underlying platform_can_send() functions.
Now, can.send() returns a boolean result to indicate whether the message
was successfully sent or not. The various platform functions differ in how
they handled the situation where all CAN transmitters are occupied. In
particular, the STM32x and STR9 implementations ignored the status returns
from the underlying libraries and so if all the CAN transmitters were busy,
the latest message simply got thrown away. Now, can.send() returns true/false
to indicate if the message really did get queued for transmission. All
platforms should behave the same as before.
2014-01-25 19:29:33 +00:00
Bogdan Marinescu
495ec9e136 Merge pull request #35 from ecdr/MiscUpdates
Misc updates
2014-01-23 02:36:40 -08:00
ecdr
71c060bb81 eLua - platform - uart - handle mark/space parity - lm3s, lpc17xx, at91sam, avr32 2014-01-22 14:19:27 -08:00