1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00

954 Commits

Author SHA1 Message Date
Martin Guy
66798da84b Fix PWM clock select commentary 2011-10-14 13:28:12 +02:00
Bogdan Marinescu
c9127c8893 another timeout type fix 2011-10-14 14:21:16 +03:00
Bogdan Marinescu
537cf8da51 added the system timer as an explicit constant in a few modules 2011-10-14 00:07:16 +03:00
Bogdan Marinescu
b12ba2194e added new convenience function to the timer module 2011-10-13 14:22:27 +03:00
Bogdan Marinescu
a46cc203c8 fix timeout data type in the RFS implementation 2011-10-13 14:12:05 +03:00
Bogdan Marinescu
1a1ae155c9 RFS_TIMER_ID now defaults to the system timer on supported platforms 2011-10-13 13:42:49 +03:00
Bogdan Marinescu
55e0b9ec9e RPC_TIMER_ID now defaults to the system timer on supported platforms 2011-10-13 13:37:46 +03:00
Bogdan Marinescu
77d543c53a fixed STR9 systimer implementation (tested) 2011-10-12 01:31:29 +03:00
Bogdan Marinescu
cc99b2d7a2 added missing operations for some platforms 2011-10-11 17:31:59 +03:00
Bogdan Marinescu
72080c34fc system timer support for STR9 (not yet tested) 2011-10-11 17:28:41 +03:00
Bogdan Marinescu
17684b1da2 Fix compilation errors for platform that won't get a system timer
There are some platform that will not get a system timer implementation
(mainly because they don't really have a user base). These are i386,
lpc288x and str7. They will continue to work without a system timer.
2011-10-11 15:45:56 +03:00
Bogdan Marinescu
026f72dd46 System timer support is now optional
Since the system timer might be too demanding for some platforms
(although this isn't currently the case for any eLua plarform) it
is now optional. Any platform that implements it must define the
PLATFORM_HAS_SYSTIMER macro in its platform_conf.h
2011-10-11 13:59:02 +03:00
Bogdan Marinescu
acba13b16f systimer support for LPC24xx 2011-10-11 01:41:14 +03:00
Bogdan Marinescu
b1b82b127e Change systimer overflow handling from timer stop to interrupt disable
When a systimer timer overflow is detected, handle it by temporarily disabling
the systimer interrupt rather than disabling the systimer completely. It gives
better accuracy and fixes some hardware-related issues on some platforms.
2011-10-11 00:44:06 +03:00
Martin Guy
8fe7d5ca9a Fix bug in AVR32 ADC code: reading write-only register adc->chdr 2011-10-10 04:23:19 +02:00
James Snyder
eea769be29 Initial fix for AVR32 ADC sequencer issues 2011-10-09 19:06:59 -05:00
Bogdan Marinescu
94cd84a5b6 added systimer support for AT91SAM7X 2011-10-10 01:24:29 +03:00
Bogdan Marinescu
7f94e898e1 Added a function to directly specify the interrupt period 2011-10-10 01:22:56 +03:00
Martin Guy
25a517d66a Fix two bugs in AVR32 PWM code
- Very low frequencies with very high clock rates (ratio > 1048576)
  selected random requencies (overflow of 20-bit period register was
  not checked

- initialization of prescaler selector to 0 was missing.
  It just happened to get 0 off the stack every time by chance (!).
2011-10-09 21:14:13 +02:00
Martin Guy
06f73e485c Add checks for invalid parameters in Lua i2c.*() and pwm.*() functions
Instead of "correcting" or ignoring bad parameter values in i2c and pwm
(see commit e6b20231b4eea4054070b1f6a4e36216e80d2d1d)
apply the eLua policy of signalling the error on the console and aborting.

All "clock" and "frequency" errors here use the same message ("frequency")
so as to reduce the firmware bloat from extra message strings.
2011-10-09 19:45:45 +02:00
Bogdan Marinescu
bed235ccdd AVR32 system timer implementation 2011-10-09 20:42:03 +03:00
Bogdan Marinescu
356e683e3a fixed invalid platform_timer_read call 2011-10-09 19:48:37 +03:00
Bogdan Marinescu
720d62909e new timer convenience function 2011-10-09 19:41:30 +03:00
Bogdan Marinescu
a9e69c72d4 Update net module with the new timer infrastructure
- change timeouts in elua_uip.c to the timer data type
- make all timer IDs in the net module default to the system timer
2011-10-08 23:24:19 +03:00
Bogdan Marinescu
57b27d05fb System timer support - WIP
1. System timer support for MBED using the Cortex M3 SysTick interrupt
2. Bugfix in the generic system timer implementation
2011-10-08 22:02:41 +03:00
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