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.
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
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.
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
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
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 =
Instead of defining the virtual timer channel twice in two .c files,
define it once in each board's platform_conf.h file. Although all the
currently-supported UC3 parts (A & B) have 3 timers, the UC3C parts have 6.
tmr.getmaxdelay() used to return -1 for the system timer and -2 for
virtual timers in the integer build due to Lua integers being signed.
This makes them return 2147483647 and 2147483646 resectively.
The I2C delay routine would very occasionally pause execution for
60 seconds then continue. This was due to an Atmel delay routine
that claimed to handle the 32-bit counter register overflowing
but didn't. Specifically, in the old code, when delay_end_cycle was
very close to 2^32, the counter register could wrap to 0 before it
was compared for being > delay_end_cycle, resulting in a 2^32-cycle
pause, about a minute. If the end_cycle were exactly 2^32-1,
the delay might have takes several minute-long cycles to finish.
This commit also fixes the bug in the SDRAM init code where the
delay code was copied from. In that case the odds of the bug biting
were very small indeed, since it was immediately after system startup
and in SDRAM init code there are no interrupt routines running.
However, the correct code is also shorter.
On Linux, the serial connection was not setup properly, which led to
weird errors in the RFS server. This fix disables any input processing
in the termios layer, thus fixing the problem. Thanks to Markus Korber
for reporting and fixing the issue.
Read from the UART file descriptor until no data can be read
anymore (POSIX only). This is needed because sometimes the
RFS server didn't read all the available data and signaled errors.
This commit fixes
src/modules/tmr.c:203: warning: implicit declaration of function 'LNUMVAL'
src/modules/tmr.c:203: error: initializer element is not constant
src/modules/tmr.c:203: error: (near initialization for 'tmr_map[11].func')
due to missing #if LUA_OPTIMIZE_MEMORY > 0
The previous Mizar32 LCD firmware had a limit of 31 bytes per
data message, while the new has no limit. This commit drops the
code that used to split long data transfers into 31-byte chunks.
When defining a user-defined character on the LCD panel, the hardware
forgets the current cursor position on the display. We used to
restore it by keeping track of the cursor in software, but now that
the LCD firmware has a "report current cursor position" command,
we simply use that to save and restore the cursor position when
defining a char. Code saving: 272 bytes.
The old firmware could not return the current cursor position, so
previously, when defining a user-definable character, it could
The new LCD PIC firmware has the ability to return the cursor position
in the LCD character RAM and the state of the buttons. This commit
implements eLua module functions to make these available to users.