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

1144 Commits

Author SHA1 Message Date
Bogdan Marinescu
9ded6db852 Implementing system timer capabilities
- the infinite timeout value is again represented by a special value
  (not a special timer ID), but this time it's a non-negative value
- all timers in the UART module default to the system timer
- all timers in the TMR module default to the system timer
- implemented a generic system timer mechanism that can be used in
  conjunction with a timer interrupt.
- implemented system timers on LM3S (tested) and STM32 (not tested).
  Both are based on the Cortex M3 SysTick timer.
2011-10-08 20:07:14 +03:00
Martin Guy
b3db818b97 Fix AVR32 PWM rturning -1 for very large values of frequency
Previously, if you set a frequency value ten times the PWM clock
frequency, it would calculate a period of 0 and return foo/0, which
gives -1 on AVR32.  With this change, everything > pwmclk sets and
returns a frequency of pwmclk.
2011-10-08 03:17:10 +02:00
Martin Guy
e1973504c0 AVR32 PWM: Improve frequency precision and reporting
Previously, pwm.setup() would set a frequency equal to or less
than the one asked for, and report an integer less than or equal
to the actual frequency set.  This change makes it set the closest
available frequency and report the closest integer to that.
2011-10-08 03:09:07 +02:00
Martin Guy
e6b20231b4 Add bounds checking for duty < 0 and freq < 1 in pwm.setup()
Previously, you could ask for a PWM frequency of 0 and negative
duty cycles, and each platform would do a different thing: failing
or setting some random values.  This change replaces such values
with the minimum, the same way that duty is bounded to 100.
2011-10-08 02:53:33 +02:00
Bogdan Marinescu
ccd3a9bdab update code to match std_get_func's new signature 2011-10-08 02:40:48 +03:00
Bogdan Marinescu
f1d105cbb8 DHCP timer now defaults to the system timer if not specified 2011-10-08 02:13:53 +03:00
Bogdan Marinescu
a6a9829ff1 Started to modify the timer infrastructure
- added explicit support for the system timer in common_tmr.c
- all the functions in the tmr module will now use the system timer
  by default (if no id is specified)
- infinite timeout will be specified by using a special timer ID
  rather than using negative timeout values (this allows the timer
  data type to be unsigned and increases the timer range)
2011-10-07 17:19:51 +03:00
Bogdan Marinescu
7ba13aaf7e build system dependency fix 2011-10-07 17:19:48 +03:00
Bogdan Marinescu
2fcba01451 Added timer with microsecond resolution in 'sim' backend
Microsecond-resolution timer for the 'sim' backend using 'gettimeofday'.
Will be used to test the new timer system.
2011-10-07 13:20:29 +03:00
James Snyder
64d93f2171 Fix typo in adc.getsamples. Should now return table of values. 2011-10-07 01:26:40 -05:00
James Snyder
1892bec9c5 Correct adispatch functionality when new connection is needed. 2011-10-06 19:48:37 -05:00
James Snyder
3ec7d8ce30 Merge branch 'master' into newrpc_merge 2011-10-06 19:01:51 -05:00
James Snyder
cc1cda9109 remove some unneeded API extensions, cleanup 2011-10-06 18:59:44 -05:00
James Snyder
f400a45c2f make adispatch compatible with new model for readable function 2011-10-06 18:53:43 -05:00
James Snyder
fb312d828c Merge branch 'master' into newrpc_merge 2011-10-06 18:25:37 -05:00
Martin Guy
29457d610b Merge branch 'master' of github.com:elua/elua 2011-10-05 23:40:10 +02:00
Martin Guy
f386633ec0 Put LUAI_MAXUPVALUES back to Lua 5.1.4 default of 60.
THe MAXUPVALUES was reduced to reduce stack and RAM usage, but turns out
to create incomprehensible erorrs for beginners when they use more than
10 global variables ina function.

This change puts is back tot eh Lua defualt, which uses 100 bytes more
RAM when parsnig functions, or 200 if they have nested functions.
This seems less bad than throwing incomprehensible errors when beginners
code the sort of things that beginners always code.
2011-10-05 23:36:41 +02:00
Martin Guy
4b6096a8dc Sort out declarations of ADC commons and platform-specific functions 2011-10-05 16:08:45 +02:00
James Snyder
210cd6f21a Fix typo in Console/Terminal arch doc 2011-10-04 21:59:06 -05:00
James Snyder
6a1e683a8f Fix typo in TCP/IP arch doc 2011-10-04 21:29:45 -05:00
James Snyder
f9eec264db Merge branch 'master' into lm3s_usb_cdc 2011-10-04 21:24:00 -05:00
Raimondas Sasnauskas
eeab1025e2 Lost SYNACK causes connection reset
==================
From: Raimondas Sasnauskas <raimondas.sasnauskas@cs.rwth-aachen.de>
Date: Sun, Sep 20, 2009 at 1:29 PM
Subject: Re: RE: Re: RE: Re: Re: RE: Bug (?) in uip TCP/IP stack: lost SYNACK causes connection reset

OK, here I'm proposing the following patch (see git diff attached).

Again the problem we face here is the subsequent SYN arriving in
UIP_SYN_RCVD state after the SYNACK packet was lost.  First, to avoid
other issues,  suggest to reset any _active_ connection where a SYN
arrives in a state != UIP_SYN_RCVD.

==================

This is a combination of the patch submitted by Raimondas Sasnauskas and
the patch applied by Oliver Schmidt to Contiki

===================
Original bug report
===================

 From: Raimondas Sasnauskas
       <raimondas.sasnauskas@cs.rwth-aachen.de>
 Subject: Bug (?) in uip TCP/IP stack: lost SYNACK causes
          connection reset
 Date: 2009-09-02 19:07:51 GMT

 Hi all,

 I've found the following issue in the TCP (UIP_ACTIVE_OPEN)
 connection establishment phase leading to connection failure.
 This happens whe the SYNACK packet gets lost during the TCP
 3-way handshake.

 Client: SYN
 Server: SYNACK (this packet gets lost)
 Client: SYN (retransmission)
 Server: ACK (<-- server thinks it's data?)
 Client: RESET (correct, no SYNACK received yet)
 Server: ABORT (got reset, aborting connection)

 I do not have a patch/workaround yet, but I think that
 correctly handling incoming TCP_SYN packets in UIP_SYN_RCVD
 state would fix this issue.

 http://article.gmane.org/gmane.network.uip.user/1506
2011-10-04 21:15:42 -05:00
Andrew Ruder
c388c3f3b3 TCP polling code can send stale/duplicate data
Here's the content of the patch (so it can be more easily
discussed if need be).  What basically happens is uip_len and
uip_slen never get reset to 0 when calling the poll handler.
Here's an example of how things go wrong:

Let's say you get some new incoming data (uip_newdata()), your
application handler processes the new data and sends something
out (thus setting uip_slen).  Back in the main loop again, you
poll a connection.  uip_slen is still set from the last send and
if your poll handler doesn't send out something new, uip ends up
just sending out the exact same data on the now polled
connection.  In every other applicable case, uip_len and
uip_slen get reset, but for whatever reason this one just got
missed...

http://article.gmane.org/gmane.network.uip.user/1312
2011-10-04 21:15:42 -05:00
Jack Elston
7fbfc2c229 UDP packet data pointed at wrong location
I have been working on implementing a port to the atmel
ATMega128 and I have noticed that sending UDP packets does not
work (the transferred data is always 0).

A look into the code reveals that in uip.c, the address of
uip_appdata gets set incorrectly.

Somewhere around line 1159 the code needs to be changed:

--- uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPTCPH_LEN];
+++ uip_appdata = &uip_buf[UIP_LLH_LEN + UIP_IPUDPH_LEN];

http://article.gmane.org/gmane.network.uip.user/68
2011-10-04 21:15:33 -05:00
Till Harbaum
2d484e1ead Fix missing UDP stats for sent/received packets
i just saw that the stats taking in uip is missing entries for udp
receive and
transmit.

To fix this insert a UIP_STAT after the udp_found label:

 udp_found:
 +  UIP_STAT(++uip_stat.udp.recv);

 And a UIP_STAT before the goto ip_send_nolen instruction:

 +  UIP_STAT(++uip_stat.udp.sent);
   goto ip_send_nolen;
2011-10-04 20:50:14 -05:00
Pablo Cossutta
fa335c481e lc-switch.h has typo in head protection macros
Another think: the LC-SWITCH.C has this two lines that are wrong:

Of course its a typo on the second one.

http://article.gmane.org/gmane.network.uip.user/15
2011-10-04 20:25:11 -05:00
Martin Guy
a11b839dd5 Respect the User's Guide by disabling a PWM channel before changing its params
It seemed to work just to change the PWM frequency and duty cycle on the fly
but the User's Guid says to disable itberfore doing this. So we do.
2011-10-05 02:44:47 +02:00
Martin Guy
7713a185bb Fix typo in commentary 2011-10-05 01:05:31 +02:00
Bogdan Marinescu
8839e93c16 Merge branch 'master' of github.com:elua/elua 2011-10-03 14:15:35 +03:00
Bogdan Marinescu
60d62078b7 Remove separate dependency step from Lua build system
The separate dependency generation step from the Lua build system
was not needed, now the dependencies are generated at the same time
as the object files.
2011-10-03 14:08:22 +03:00
Martin Guy
121a70b8b1 New firmware works with no delays and max speed of 50000Hz
The new LCD firmware doesn't need the caller to wait after each command:
it stretches the clock instead. Actually, it works at 68kHz too, but
there is a non-working range from 55 to 66kHz.
We set it to 50000Hz to have reliable operation and allow for clock drift.
2011-10-03 06:36:55 +02:00
Martin Guy
2c7d3a3743 Increase LCD I2C bus frequency to fit with new LCD module firmware.
The new firmware can run at up to 68kHz, so increase the I2C bus speed
to 60000Hz
2011-10-03 02:29:57 +02:00
Martin Guy
a9c7041af7 Use new hard reset command to reset LCD module.
We just changed LCD command 0 from a no-op to a speciall-recognized
hardware reset. This is essential because the LCD controller's reset line
is not connected to the AVR32's reset line, so if the AVR32 is reset,
the LCD is left in an unknown, possible unusable, state.
2011-10-03 02:14:28 +02:00
James Snyder
8f0bf4c7d2 set default MAC on soldercore 2011-09-29 15:05:24 -05:00
James Snyder
7b8642502b Fix uIP DHCP Lease Bug http://osdir.com/ml/network.uip.user/2007-12/msg00012.html 2011-09-28 17:13:42 -05:00
Martin Guy
f048bece4b Change LCD I2C slave addresses to 7C-7F
The old slave addresses, F2, F3, F6, F7 are reserved for 10-bit
I2C addressing.  This changes them to values that are least likely
to conflist with other devices: 7C-7F are registered to two LCD display
devices.
2011-09-28 20:29:37 +02:00
Martin Guy
a05c209ab2 Remove documentation for non-existent str9.rtc module 2011-09-27 15:09:11 +02:00
James Snyder
0d54061858 working PWM for SolderCore 2011-09-25 16:48:58 -05:00
Martin Guy
99f696451c Add BUILD_LUA_INT_HANDLERS to Mizar32 default build 2011-09-25 17:05:28 +02:00
Martin Guy
f6783e40ce Add math.floor() and math.ceil() identity functions to integral mathlib
In integer math, floor() and ceil() give the same value, but
having them included in the integer library as functions that return
their argument allows you more easily to write code that works unchanged
in both integer and floating point versions of Lua.
2011-09-23 17:41:24 +02:00
Martin Guy
30b4f7a6dd Insert setup delay for repeated START condition (missed from last commit) 2011-09-22 18:26:28 +02:00
Martin Guy
5d5443d67e Implement STOP and repeated START condition setup times from I2C spec.
The code for the bitbanger, taken from wikipedia, in turn taken from
http://www.nctutwt.net/wiki/doku.php?id=wiki:summer2010:i2c
does a STOP condition by raising SCL and immediately raising SDA, but
in the I2C spec, there is a minimum STOP setup time of 4ms between these
transitions (I2C spec, doc UM10204, table 6/figure 27, pp.37-38).

Similarly, a repeated START has a setup time of minimum 4.7us between
SCL going high and SDA going low, which the code did not contain.

This patch inserts these delays to conform better to the I2C spec,
even though all tested devices "seemed to work" without them.
2011-09-22 16:49:19 +02:00
James Snyder
571d9f0d6c fix adc configuration for LM3S9B/LM3S9D 2011-09-13 20:41:16 -05:00
James Snyder
6f6b272fd9 Clean up CDC-USB support 2011-09-13 19:44:08 -05:00
Martin Guy
22f08c454d Fix markup in PWM documentation 2011-09-13 19:34:27 +02:00
James Snyder
6ebaaa69b8 Initial working USB CDC support for LM3S 2011-09-06 20:05:23 -05:00
Martin Guy
ade99720cd Merge branch 'master' of github.com:elua/elua 2011-08-02 16:18:42 +02:00
Martin Guy
1c1a59851d Split platform_pwm_op(id, op[, data]) into four distinct functions
platform_pwm_op( id, op, data ) did four unrelated tasks, switching on the
"op" parameter:
op==PLATFORM_PWM_OP_SET_CLOCK took a frequency and returned a frequency
op==PLATFORM_PWM_OP_GET_CLOCK took nothing returned a frequency
op==PLATFORM_PWM_OP_START and _STOP both took nothing and returned nothing

this patch replaces it with:
clock = platform_pwm_set_clock( id, clock)
clock = platform_pwm_get_clock( id )
platform_pwm_start( id ) and
platform_pwm_stop( id )

with resulting clarity in the documentation and smaller, faster code.

This does not affect the Lau interface.
2011-08-02 16:15:59 +02:00
James Snyder
ee759a1c4b fix typo in cyclic interrupt handling on stm32, don't enable interrupt by default.. require sei 2011-08-01 21:09:21 -05:00
James Snyder
e64f9ef3bb Merge branch 'master' of github.com:elua/elua 2011-08-01 20:32:16 -05:00