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

1056 Commits

Author SHA1 Message Date
Martin Guy
939cdbc3fd Convert AVR32 i2c_{send,recv} to take 7-bit addresses 2012-03-19 15:01:59 +01:00
Martin Guy
42af821686 AVR32 bugfix: Include usb-cdc.c in the Lua build system too. 2012-03-19 14:16:58 +01:00
Martin Guy
976d0f5111 Refactor AVR32 I2C code to have I2C packet-level send() and recv() routines
This introduces i2c_send() and i2c_recv in the AVR32 code that send/receive
whole I2C messages from start to optional stop.
2012-03-19 12:45:59 +01:00
Martin Guy
8b0bb4bbb9 Ensure Mizar32 i2c pins are initialized if i2c.setup() is not called 2012-03-19 12:12:29 +01:00
Martin Guy
374a21f15e Bug fix: always return 0 from Lua functions
Many mizar32.lcd() Lua functions used to tail-call the i2c_send_command()
functions, whereas they should explicitly return 0, the number of return
values from the Lua function. OK, i2c_send_command did return 0 but this
will change in future when it can detect slave presence and collisions.
2012-03-19 11:45:00 +01:00
Martin Guy
49ab7be03e Fix typo in docs 2012-03-15 09:20:57 +01:00
Martin Guy
5b141dd63b .gitignore: Ignore auto-generated file inc/git_version.h 2012-03-15 09:19:44 +01:00
Martin Guy
27da495151 Document pio.decode() 2012-03-08 21:23:13 +01:00
Martin Guy
ff2ba18585 Fix typos in PIO refman 2012-03-08 20:47:26 +01:00
Martin Guy
f9c3f2bf1c AVR32: In pio.decode(), reverse the mapping of hardware pins to PX names
On AVR32UC3A0 parts, the GPIO pins are named PA0-31, PB0-31, PC0-5 and
PX0-39. There is no port X: these pins map to five backwards ranges of
bits in the third and fourth sets of GPIO registers (where PC0-5 are
the first six of the third register set).
Already we map pio.PX_nn names to these values, and this commit puts the
reverse mapping into place in pio.decode().

Test program to verify correct mapping:

function eval(s)
  return( loadstring( "return(" .. s .. ")" ) )()
end

for i=0,39 do
  name = "pio.PX_" .. tostring(i)
  gpio = eval(name)
  print( name, gpio, pio.decode(gpio) )
end
2012-03-08 20:36:35 +01:00
James Snyder
f3e0620c98 Merge branch 'include_git_rev' 2012-03-08 12:07:56 -06:00
Martin Guy
90897d2d02 Save 4 bytes RAM per structure by reordering struct members
Structure size is 12 byte instead of 16 with GCC on x86,
probably also on others.
2012-02-26 04:14:53 +01:00
Martin Guy
55b78b50ac Build system changes to allow building with UIP_CONF_IPV6
These changes allow you to "#define UIP_CONF_IPV6 1" in uip-conf.h
for an IPV6-capable network layer.
This also removes a pointless inclusion in avr32/uip-conf.h
The changes to the other three .c files (from "build.h" to "platform_conf.h")
are just orthogonal future-proofing.
2012-02-19 18:25:37 +01:00
Martin Guy
35861a2d3d Restore original licence on uip-conf.h
Luminary Micros replaced the original permissive Swedish Institute
of Computer Science licence with their own one restricting it to
use on LM devices only. This put the original license back.
See http://uip-stack.cvs.sourceforge.net/viewvc/uip-stack/uip/unix/uip-conf.h
2012-02-19 18:05:52 +01:00
Martin Guy
37bc042bda Fix indentation 2012-02-19 11:35:59 +01:00
Martin Guy
406cfac9c9 AVR32: Defer SPI clock setup to when platform_spi_setup() is called
This change defers enabling the SPI clocks to platform_spi_setup()
so that, if SPI ports are not used and BUILD_MMCFS is disabled,
power consumption is reduced.
2012-02-19 10:35:11 +01:00
Martin Guy
1f94b2fab4 Remove unused declaration for a nonexistent function 2012-02-19 09:19:31 +01:00
Martin Guy
d2f5032d63 Remove uart.SYS_TIMER and net.SYS_TIMER (use tmr.SYS_TIMER)
This change removes the extra undocumented uart.SYS_TIMER and
net.SYS_TIMER constants, which are equal to tmr.SYS_TIMER.
The documentation says to use tmr.SYS_TIMER and in the rare case
of uart or net being compiled in but not tmr, the system timer
can be had by using nil or omitting the parameter.
2012-02-18 14:40:50 +01:00
James Snyder
28d44765c3 Merge branch 'master' into newsite 2012-02-07 15:01:54 -06:00
Martin Guy
6ed4b5208e Another fix in the CRLF handler: don't drop the second one of repeated
newline characters.

The console used to drop the second one of repeated \r or \n characters
because it would stash the second one in std_prev_char, then at the start
of the next call to std_read(), would poke the \r into the start of the
line buffer, returning a line that began with \r or \n.
This change processes the lookahead character the same as regular ones.
2012-02-07 12:55:14 +01:00
Martin Guy
640f9b970e Echo the lookahead character on console input
Previously, when pasting multiple lines into the console, the first
character of half the lines would not be echoed.  This was due to it being
slurped up by the CRLF lookahead detector, but not being echoed when it was
regurgitated. This change fixes that.
2012-02-07 12:34:05 +01:00
Martin Guy
c819565ebb Add missing constant uart.FLOW_NONE when optram==0
and reorder the optram=0 constants to match the optram>0 ones so that
it is more obvious to the eye whether they correspond or not.
2012-02-05 10:24:45 +01:00
Martin Guy
be9c9e46a7 Fix removal of UART buffer with uart.set_buffer(id, 0)
Previously, if you removed a buffer from e uart, the buffer was
removed but the interrupt routine was left intalled, which made
the interpreter hang if you typed a character on the serial port.
Now you can enable and disable UART buffers.

This also changes the order of interrupt handler to
- install the handler
- enable the interrupt
instead of the other way round, so there is no window of time with the
interrupt enabled but no handler installed.
2012-02-01 21:33:22 +01:00
Martin Guy
005d783c14 Bug fix: Allow more than one call to uart.set_buffer()
Previously, every call except the first one to uart.set_buffer()
with a buffer size > 0 would fail, as platform_cpu_set_int() returns
whether it used to be enabled or not, which is 0 the first time
(which happens to == PLATFORM_INT_OK) but 1 every time after that.
This change makes 0 and 1 success; all failure values are negative
so that people can now change UART buffer sizes.
2012-02-01 21:19:27 +01:00
Martin Guy
fe8b1d8630 Rework Mizar32 config so that UART buffering is still available
The usb-cdc config removed UART buffering completely, whereas
it should still be available via uart.set_buffer().
2012-02-01 18:56:33 +01:00
Martin Guy
a2c22b0aac Make compilation of usb-cdc.c conditional on BUILD_USB_CDC
...instead of compiling it and having the linker drop the unused symbols.
2012-02-01 18:40:08 +01:00
Martin Guy
cd81e0d3dd avr32 usb-cdc cleanup: remove tabs and ^Ms and add Atmel copyright 2012-02-01 18:28:13 +01:00
Martin Guy
3e48d16846 AVR32 bugfix: pwm.setclock() used to stop the system timer.
Now that the system timer uses PWM clock B, the pwm setclock() code
needs to read-modify-write the mode register instead of just setting it.
The most obvious symptom was that after a call to pwm.setclock() you
needed to press enter twice to get a new Lua prompt instead of once.
2012-02-01 15:26:23 +01:00
Martin Guy
d19bb6537a Fix typo in commentary 2012-02-01 15:05:22 +01:00
Martin Guy
ca12cd69e3 Drop outdated commentary 2012-01-30 17:18:18 +01:00
James Snyder
f045668c61 Merge pull request #8 from elua/avr32_usbcdc
This patch adds support for the USB-CDC (UART on USB) for avr32.
2012-01-29 11:16:56 -08:00
Nuccio Raciti
4a67f9dd5c This patch adds support for the USB-CDC (UART on USB)
for avr32.
It was tested *only* on a Mizar32 board.

Signed-off-by: Nuccio Raciti <raciti.nuccio@gmail.com>
2012-01-27 21:34:05 +01:00
Martin Guy
ac7677284e Mizar32: Disable FOSC32 again, which doesn't work in the hardware 2012-01-23 14:29:26 +01:00
Martin Guy
3e1398e987 Add math.pow() to integer version of math library
An integer version of the power function exists anyway for the ^ operator,
so create a binding to its synonym in the math library when LUA_NUMBER_INTEGRAL
2012-01-23 13:22:06 +01:00
James Snyder
b045088f65 Fix git command check to look for code 0 return 2012-01-21 16:23:31 -06:00
Martin Guy
b72f620aed Fix to previous commit: unsigned values never look negative! 2012-01-21 20:00:34 +01:00
Martin Guy
84a17973fb Merge branch 'master' of github.com:elua/elua 2012-01-21 19:32:37 +01:00
Martin Guy
0e09fd9006 Reject negative frequency values in adc.setclock() 2012-01-21 19:30:31 +01:00
Bogdan Marinescu
6f93ebdd29 Merge branch 'master' of github.com:elua/elua 2012-01-21 17:33:08 +02:00
Martin Guy
69eb5cc478 Put the order of timer parameters back to what it used to be
This patch undoes the change in the order of timer parameters for:
net.accept() net.recv() tmr.delay() tmr.setclock() tmr.set_match_int()
tmr.gettimediff()  and also changes the new tmr.getdiffnow() to have the
same parameter ordering as the others.
The default timer ID (the systimer), which previously was obtained with an
optional last parameter, is now obtained by supplying nil as the timer ID.
2012-01-21 17:30:38 +02:00
Martin Guy
b95ec14fa9 Reconfigure Mizar32 for product launch
The product launch configs are to have the eLua shell only in the
larger models and as many basic modules as will fit in the 128K version
2012-01-21 15:16:30 +01:00
Martin Guy
3f48d87780 Fix compiler warning about pointer signedness 2012-01-21 14:01:25 +01:00
Martin Guy
d0ac60c65b AVR32 config changes fot default CPU, allocator and memory use
Changes the default Mizar32 CPU to the 256K model,
the default allocator for the 128K Mizar32 to simple (the smallest)
the default allocator for other Mizar32s to multiple to avoid newlib's
  dlmalloc bug
and only use one memory region on AVR32 platforms when newlib or simple
  for the same newlib dlmalloc bug and because simple can only handle
  one region
2012-01-21 12:24:35 +01:00
Martin Guy
34c634dbf7 AVR32: Configure ADC within spec and at optimal values
The previous Atmel code didn't set the PRESCAL filend, so overclocked
the ADC at 7.5Mhz or 8.25Mhz (according to PBA_FREQ) instead of the
maximum of 5MHz for 10-bit conversions and 8MHz for 8-bit.
It also set the sample-hold and startup times to their maxima instead
of just within spec.

This change calculates the optimal in-spec values for these fields,
also improving the maximum sampling rate, from 64ks/sec to 71ks/sec
and is preparatory work for being able to set the sampling rate.

Tested on Mizar32 and EVK1100
2012-01-21 09:41:54 +01:00
James Snyder
ed9793a42e Add support for git version determination to SCons build system 2012-01-20 18:15:53 -06:00
James Snyder
8060e0e2c9 Merge branch 'master' into include_git_rev 2012-01-20 17:22:56 -06:00
James Snyder
d608453878 Apply strexh/strexb fix to lpc17xx as well 2012-01-20 17:20:51 -06:00
James Snyder
879642e1e1 Workaround for strexh/strexb same register error: http://lists.gnu.org/archive/html/bug-binutils/2011-12/msg00112.html 2012-01-18 19:01:43 -06:00
Martin Guy
a77fc80604 Tiny optimization in AVR32 UART code
The values for the stopbit defines happen to be the same in eLua
headers and avr32 headers, so check for this and when true replace
a no-op switch statement with an =
2012-01-17 11:58:04 +01:00
Martin Guy
c8a82fa8bf Include 32768Hz crystal on Mizar32 - now it will be there. 2012-01-16 10:14:16 +01:00