2008-07-29 11:08:54 +00:00
|
|
|
// Platform-specific functions
|
|
|
|
|
|
|
|
#ifndef __PLATFORM_H__
|
|
|
|
#define __PLATFORM_H__
|
|
|
|
|
|
|
|
#include "devman.h"
|
|
|
|
#include "type.h"
|
2010-09-26 18:54:18 +00:00
|
|
|
#include "elua_int.h"
|
2008-07-29 11:08:54 +00:00
|
|
|
|
- Buffer refactored to handle multibyte data.
Code which was previously using buffer has been updated to work with the
changes.
API has also changed in accordance:
int buf_set(unsigned resid, unsigned resnum, u8 logsize, size_t dsize);
int buf_is_enabled( unsigned resid, unsigned resnum );
unsigned buf_get_size( unsigned resid, unsigned resnum );
unsigned buf_get_count( unsigned resid, unsigned resnum );
int buf_write( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
int buf_read( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
Essentially buf_rx_cb and buf_get_char have been renamed to buf_write and
buf_read. For these, one now passes a pointer to where the data is coming
from or going to, and a dsize parameter indicating how many bytes should be
copied. Also, buf_set takes this same dsize parameter, and keeps it in the
struct. This allows us to ensure that when data is read or written the
number of bytes matches the buffer element size.
I thought about maintaining compatibility functions to provide the original
buf_rx_cb and buf_get_byte API calls, however there weren't a large number
of uses of buf, so it wasn't hard to convert things.
One caveat: BUF_MOD_INCR assumes that byte counts for alternate type sizes
will be powers of 2.
Also, BUF_SIZE_xx's are assumed to refer to element counts.
- UART buffering enabled on LM3S
This doesn't include switching the ADC code over to using these buffers quite
yet.
I'm open to comments on these modifications if theres a better or simpler
approach. I've checked to make sure buffers work on LM3S, but I don't own any
other platforms to make sure there aren't unintended side-effects.
2009-02-09 03:43:47 +00:00
|
|
|
// Error / status codes
|
2008-07-29 11:08:54 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_ERR,
|
- Buffer refactored to handle multibyte data.
Code which was previously using buffer has been updated to work with the
changes.
API has also changed in accordance:
int buf_set(unsigned resid, unsigned resnum, u8 logsize, size_t dsize);
int buf_is_enabled( unsigned resid, unsigned resnum );
unsigned buf_get_size( unsigned resid, unsigned resnum );
unsigned buf_get_count( unsigned resid, unsigned resnum );
int buf_write( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
int buf_read( unsigned resid, unsigned resnum, t_buf_data *data, size_t dsize );
Essentially buf_rx_cb and buf_get_char have been renamed to buf_write and
buf_read. For these, one now passes a pointer to where the data is coming
from or going to, and a dsize parameter indicating how many bytes should be
copied. Also, buf_set takes this same dsize parameter, and keeps it in the
struct. This allows us to ensure that when data is read or written the
number of bytes matches the buffer element size.
I thought about maintaining compatibility functions to provide the original
buf_rx_cb and buf_get_byte API calls, however there weren't a large number
of uses of buf, so it wasn't hard to convert things.
One caveat: BUF_MOD_INCR assumes that byte counts for alternate type sizes
will be powers of 2.
Also, BUF_SIZE_xx's are assumed to refer to element counts.
- UART buffering enabled on LM3S
This doesn't include switching the ADC code over to using these buffers quite
yet.
I'm open to comments on these modifications if theres a better or simpler
approach. I've checked to make sure buffers work on LM3S, but I don't own any
other platforms to make sure there aren't unintended side-effects.
2009-02-09 03:43:47 +00:00
|
|
|
PLATFORM_OK,
|
2009-02-10 17:54:01 +00:00
|
|
|
PLATFORM_UNDERFLOW = -1
|
2008-07-29 11:08:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Platform initialization
|
|
|
|
int platform_init();
|
2010-11-03 23:57:27 +00:00
|
|
|
void platform_int_init();
|
2008-07-29 11:08:54 +00:00
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
// PIO subsection
|
|
|
|
// "Virtual ports": 16 ports (PA...PF), 32-bits each for a total of 512 I/O pins.
|
|
|
|
// They are coded within a single integer, where the high part encodes the port
|
|
|
|
// number, while the lower part encodes the pin number
|
|
|
|
|
|
|
|
typedef u32 pio_type;
|
|
|
|
typedef u32 pio_code;
|
|
|
|
#define PLATFORM_IO_PORTS 16
|
|
|
|
#define PLATFORM_IO_PORTS_BITS 4
|
|
|
|
#define PLATFORM_IO_PINS 32
|
|
|
|
#define PLATFORM_IO_PINS_BITS 5
|
|
|
|
#define PLATFORM_IO_FULL_PORT_BIT 14
|
|
|
|
#define PLATFORM_IO_FULL_PORT_MASK ( 1 << PLATFORM_IO_FULL_PORT_BIT )
|
|
|
|
#define PLATFORM_IO_ENCODE( port, pin, full ) ( ( ( port ) << PLATFORM_IO_PINS_BITS ) | ( pin ) | ( ( full ) ? PLATFORM_IO_FULL_PORT_MASK : 0 ) )
|
|
|
|
#define PLATFORM_IO_GET_PORT( code ) ( ( ( code ) >> PLATFORM_IO_PINS_BITS ) & ( ( 1 << PLATFORM_IO_PORTS_BITS ) - 1 ) )
|
2009-02-10 17:54:01 +00:00
|
|
|
#define PLATFORM_IO_GET_PIN( code ) ( ( code ) & ( ( 1 << PLATFORM_IO_PINS_BITS ) - 1 ) )
|
2008-07-29 11:08:54 +00:00
|
|
|
#define PLATFORM_IO_IS_PORT( code ) ( ( ( code ) & PLATFORM_IO_FULL_PORT_MASK ) != 0 )
|
|
|
|
#define PLATFORM_IO_ALL_PINS 0xFFFFFFFFUL
|
|
|
|
#define PLATFORM_IO_ENC_PORT 1
|
|
|
|
#define PLATFORM_IO_ENC_PIN 0
|
|
|
|
|
2009-02-16 20:18:48 +00:00
|
|
|
#define PLATFORM_IO_READ_IN_MASK 0
|
|
|
|
#define PLATFORM_IO_READ_OUT_MASK 1
|
|
|
|
|
2008-07-29 11:08:54 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Pin operations
|
|
|
|
PLATFORM_IO_PIN_SET,
|
|
|
|
PLATFORM_IO_PIN_CLEAR,
|
|
|
|
PLATFORM_IO_PIN_GET,
|
|
|
|
PLATFORM_IO_PIN_DIR_INPUT,
|
|
|
|
PLATFORM_IO_PIN_DIR_OUTPUT,
|
2008-08-27 20:05:09 +00:00
|
|
|
PLATFORM_IO_PIN_PULLUP,
|
|
|
|
PLATFORM_IO_PIN_PULLDOWN,
|
|
|
|
PLATFORM_IO_PIN_NOPULL,
|
2008-07-29 11:08:54 +00:00
|
|
|
// Port operations
|
|
|
|
PLATFORM_IO_PORT_SET_VALUE,
|
|
|
|
PLATFORM_IO_PORT_GET_VALUE,
|
|
|
|
PLATFORM_IO_PORT_DIR_INPUT,
|
2009-01-27 20:49:45 +00:00
|
|
|
PLATFORM_IO_PORT_DIR_OUTPUT
|
2008-07-29 11:08:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The platform I/O functions
|
|
|
|
int platform_pio_has_port( unsigned port );
|
2008-08-02 18:01:01 +00:00
|
|
|
const char* platform_pio_get_prefix( unsigned port );
|
2008-07-29 11:08:54 +00:00
|
|
|
int platform_pio_has_pin( unsigned port, unsigned pin );
|
|
|
|
pio_type platform_pio_op( unsigned port, pio_type pinmask, int op );
|
|
|
|
|
2011-10-08 20:07:14 +03:00
|
|
|
// *****************************************************************************
|
|
|
|
// Timer subsection
|
|
|
|
|
|
|
|
// The ID of the system timer
|
|
|
|
#define PLATFORM_TIMER_SYS_ID 0x100
|
|
|
|
|
|
|
|
#if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_INTEGRAL_LONGLONG )
|
|
|
|
// Maximum values of the system timer
|
|
|
|
#define PLATFORM_TIMER_SYS_MAX ( ( 1LL << 32 ) - 2 )
|
|
|
|
// Timer data type
|
|
|
|
typedef u32 timer_data_type;
|
|
|
|
#else
|
|
|
|
// Maximum values of the system timer
|
|
|
|
#define PLATFORM_TIMER_SYS_MAX ( ( 1LL << 52 ) - 2 )
|
|
|
|
// Timer data type
|
|
|
|
typedef u64 timer_data_type;
|
|
|
|
#endif // #if defined( LUA_NUMBER_INTEGRAL ) && !defined( LUA_INTEGRAL_LONGLONG )
|
|
|
|
|
|
|
|
// This constant means 'infinite timeout'
|
|
|
|
#define PLATFORM_TIMER_INF_TIMEOUT ( PLATFORM_TIMER_SYS_MAX + 1 )
|
|
|
|
|
|
|
|
// System timer frequency
|
|
|
|
#define PLATFORM_TIMER_SYS_FREQ 1000000
|
|
|
|
|
|
|
|
// Interrupt types
|
|
|
|
#define PLATFORM_TIMER_INT_ONESHOT 1
|
|
|
|
#define PLATFORM_TIMER_INT_CYCLIC 2
|
|
|
|
|
|
|
|
// Match interrupt error codes
|
|
|
|
#define PLATFORM_TIMER_INT_OK 0
|
|
|
|
#define PLATFORM_TIMER_INT_TOO_SHORT 1
|
|
|
|
#define PLATFORM_TIMER_INT_TOO_LONG 2
|
|
|
|
#define PLATFORM_TIMER_INT_INVALID_ID 3
|
|
|
|
|
|
|
|
// Timer operations
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_TIMER_OP_START,
|
|
|
|
PLATFORM_TIMER_OP_READ,
|
|
|
|
PLATFORM_TIMER_OP_SET_CLOCK,
|
|
|
|
PLATFORM_TIMER_OP_GET_CLOCK,
|
|
|
|
PLATFORM_TIMER_OP_GET_MAX_DELAY,
|
|
|
|
PLATFORM_TIMER_OP_GET_MIN_DELAY,
|
|
|
|
PLATFORM_TIMER_OP_GET_MAX_CNT
|
|
|
|
};
|
|
|
|
|
|
|
|
// The platform timer functions
|
|
|
|
int platform_timer_exists( unsigned id );
|
|
|
|
void platform_timer_delay( unsigned id, timer_data_type delay_us );
|
|
|
|
void platform_s_timer_delay( unsigned id, timer_data_type delay_us );
|
|
|
|
timer_data_type platform_timer_op( unsigned id, int op, timer_data_type data );
|
|
|
|
timer_data_type platform_s_timer_op( unsigned id, int op, timer_data_type data );
|
|
|
|
int platform_timer_set_match_int( unsigned id, timer_data_type period_us, int type );
|
|
|
|
int platform_s_timer_set_match_int( unsigned id, timer_data_type period_us, int type );
|
|
|
|
timer_data_type platform_timer_get_diff_us( unsigned id, timer_data_type end, timer_data_type start );
|
|
|
|
// System timer functions
|
|
|
|
timer_data_type platform_timer_read_sys();
|
|
|
|
// The next 3 functions need to be implemented only if the generic system timer mechanism
|
|
|
|
// (src/common.c:cmn_systimer*) is used by the backend
|
|
|
|
u64 platform_timer_sys_raw_read();
|
|
|
|
void platform_timer_sys_stop();
|
|
|
|
void platform_timer_sys_start();
|
|
|
|
|
|
|
|
// Convenience macros
|
|
|
|
#define platform_timer_read( id ) platform_timer_op( id, PLATFORM_TIMER_OP_READ, 0 )
|
|
|
|
#define platform_timer_start( id ) platform_timer_op( id, PLATFORM_TIMER_OP_START, 0 )
|
|
|
|
#define platform_timer_get_diff_crt( id, v ) platform_timer_get_diff_us( id, platform_timer_read( id ), v )
|
|
|
|
|
2009-06-26 23:38:02 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// CAN subsection
|
|
|
|
|
|
|
|
// Maximum length for any CAN message
|
|
|
|
#define PLATFORM_CAN_MAXLEN 8
|
|
|
|
|
2009-11-14 22:56:23 +00:00
|
|
|
// eLua CAN ID types
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ELUA_CAN_ID_STD = 0,
|
|
|
|
ELUA_CAN_ID_EXT
|
|
|
|
};
|
|
|
|
|
2009-06-26 23:38:02 +00:00
|
|
|
int platform_can_exists( unsigned id );
|
|
|
|
u32 platform_can_setup( unsigned id, u32 clock );
|
|
|
|
void platform_can_send( unsigned id, u32 canid, u8 idtype, u8 len, const u8 *data );
|
2010-12-06 23:26:29 +00:00
|
|
|
int platform_can_recv( unsigned id, u32 *canid, u8 *idtype, u8 *len, u8 *data );
|
2009-06-26 23:38:02 +00:00
|
|
|
|
2008-07-29 11:08:54 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// SPI subsection
|
|
|
|
|
|
|
|
// There are 4 "virtual" SPI ports (SPI0...SPI3).
|
|
|
|
#define PLATFORM_SPI_TOTAL 4
|
|
|
|
|
|
|
|
// SPI mode
|
|
|
|
#define PLATFORM_SPI_MASTER 1
|
|
|
|
#define PLATFORM_SPI_SLAVE 0
|
|
|
|
// SS values
|
|
|
|
#define PLATFORM_SPI_SELECT_ON 1
|
|
|
|
#define PLATFORM_SPI_SELECT_OFF 0
|
|
|
|
// SPI enable/disable
|
|
|
|
#define PLATFORM_SPI_ENABLE 1
|
|
|
|
#define PLATFORM_SPI_DISABLE 0
|
|
|
|
|
|
|
|
// Data types
|
|
|
|
typedef u32 spi_data_type;
|
|
|
|
|
|
|
|
// The platform SPI functions
|
|
|
|
int platform_spi_exists( unsigned id );
|
|
|
|
u32 platform_spi_setup( unsigned id, int mode, u32 clock, unsigned cpol, unsigned cpha, unsigned databits );
|
|
|
|
spi_data_type platform_spi_send_recv( unsigned id, spi_data_type data );
|
|
|
|
void platform_spi_select( unsigned id, int is_select );
|
|
|
|
|
|
|
|
// *****************************************************************************
|
|
|
|
// UART subsection
|
|
|
|
|
|
|
|
// There are 4 "virtual" UART ports (UART0...UART3).
|
|
|
|
#define PLATFORM_UART_TOTAL 4
|
|
|
|
|
|
|
|
// Parity
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_UART_PARITY_EVEN,
|
|
|
|
PLATFORM_UART_PARITY_ODD,
|
|
|
|
PLATFORM_UART_PARITY_NONE
|
|
|
|
};
|
|
|
|
|
|
|
|
// Stop bits
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_UART_STOPBITS_1,
|
|
|
|
PLATFORM_UART_STOPBITS_1_5,
|
|
|
|
PLATFORM_UART_STOPBITS_2
|
|
|
|
};
|
|
|
|
|
2011-01-16 00:23:19 +00:00
|
|
|
// Flow control types (this is a bit mask, one can specify PLATFORM_UART_FLOW_RTS | PLATFORM_UART_FLOW_CTS )
|
|
|
|
#define PLATFORM_UART_FLOW_NONE 0
|
|
|
|
#define PLATFORM_UART_FLOW_RTS 1
|
|
|
|
#define PLATFORM_UART_FLOW_CTS 2
|
|
|
|
|
2008-07-29 11:08:54 +00:00
|
|
|
// The platform UART functions
|
|
|
|
int platform_uart_exists( unsigned id );
|
|
|
|
u32 platform_uart_setup( unsigned id, u32 baud, int databits, int parity, int stopbits );
|
2011-01-16 00:23:19 +00:00
|
|
|
int platform_uart_set_buffer( unsigned id, unsigned size );
|
2008-07-29 11:08:54 +00:00
|
|
|
void platform_uart_send( unsigned id, u8 data );
|
2011-01-16 00:23:19 +00:00
|
|
|
void platform_s_uart_send( unsigned id, u8 data );
|
2011-10-08 20:07:14 +03:00
|
|
|
int platform_uart_recv( unsigned id, unsigned timer_id, timer_data_type timeout );
|
|
|
|
int platform_s_uart_recv( unsigned id, timer_data_type timeout );
|
2011-01-16 00:23:19 +00:00
|
|
|
int platform_uart_set_flow_control( unsigned id, int type );
|
|
|
|
int platform_s_uart_set_flow_control( unsigned id, int type );
|
2008-07-29 11:08:54 +00:00
|
|
|
|
2008-08-18 16:29:09 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// PWM subsection
|
|
|
|
|
|
|
|
// There are 16 "virtual" PWM channels (PWM0...PWM15)
|
|
|
|
#define PLATFORM_PWM_TOTAL 16
|
|
|
|
|
|
|
|
// The platform PWM functions
|
|
|
|
int platform_pwm_exists( unsigned id );
|
|
|
|
u32 platform_pwm_setup( unsigned id, u32 frequency, unsigned duty );
|
2011-08-02 16:15:59 +02:00
|
|
|
void platform_pwm_start( unsigned id );
|
|
|
|
void platform_pwm_stop( unsigned id );
|
|
|
|
u32 platform_pwm_set_clock( unsigned id, u32 data );
|
|
|
|
u32 platform_pwm_get_clock( unsigned id );
|
2008-08-18 16:29:09 +00:00
|
|
|
|
2008-09-18 20:22:15 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// CPU specific functions
|
|
|
|
|
2010-09-26 18:54:18 +00:00
|
|
|
#define PLATFORM_CPU_DISABLE 0
|
|
|
|
#define PLATFORM_CPU_ENABLE 1
|
|
|
|
|
2010-11-03 23:57:27 +00:00
|
|
|
// Interrupt functions return status
|
|
|
|
#define PLATFORM_INT_OK 0
|
|
|
|
#define PLATFORM_INT_GENERIC_ERROR ( -1 )
|
|
|
|
#define PLATFORM_INT_INVALID ( -2 )
|
|
|
|
#define PLATFORM_INT_NOT_HANDLED ( -3 )
|
2010-11-04 22:40:09 +00:00
|
|
|
#define PLATFORM_INT_BAD_RESNUM ( -4 )
|
2010-11-03 23:57:27 +00:00
|
|
|
|
2010-09-26 18:54:18 +00:00
|
|
|
int platform_cpu_set_global_interrupts( int status );
|
|
|
|
int platform_cpu_get_global_interrupts();
|
|
|
|
int platform_cpu_set_interrupt( elua_int_id id, elua_int_resnum resnum, int status );
|
|
|
|
int platform_cpu_get_interrupt( elua_int_id id, elua_int_resnum resnum );
|
2010-11-03 23:57:27 +00:00
|
|
|
int platform_cpu_get_interrupt_flag( elua_int_id id, elua_int_resnum resnum, int clear );
|
2008-09-26 20:41:11 +00:00
|
|
|
u32 platform_cpu_get_frequency();
|
2008-09-18 20:22:15 +00:00
|
|
|
|
2009-01-21 23:40:34 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// The platform ADC functions
|
2009-01-27 20:49:45 +00:00
|
|
|
|
Fairly large number of changes in here to make adc work with lua's provided
buf.c.
The smoothing buffer is still kept separate from the main buffering system,
but as samples come in via interrupt, they are placed into a "standard" elua
buf. The size of this buf is configured according to whether one is grabbing
a bunch of samples rapidly (burst), or singly in order to accommodate the
expected number of incoming samples. If smoothing is enabled, incoming
samples are claimed until the smoothing buffer is full, and then remaining
samples are left in the main buffer until they are collected. This means that
whether one is collecting single samples or samples at burst rate, and
smoothing is enabled, the filter will only be providing samples that have
enough history.
Added a function to manually flush both smoothing and main buffers.
This would be useful if you know your state has changed and you only want
fresh samples that are going to be collected after a flush.
Also, a lot of functionality moved into elua_adc.c and common.c
(boundaries for what belongs where, might be evaluated), reducing the number
of platform.c specific functions dramatically.
Basic functionality seems to be working, but some more testing should be done.
Also, given that there's now a dynamic buffer behind everything, a shift in
the way sampling is handled could be done:
sample and burst functions could be made to be non-blocking, and to never
return anything except for errors.
a separate getsamples function could be used for removing samples collected by
either function from the buffer.
Suggestions are welcome as it would be nice to keep usage paradigms stable
after the 0.6 release.
2009-02-16 00:53:00 +00:00
|
|
|
// Functions requiring platform-specific implementation
|
2011-10-05 16:08:45 +02:00
|
|
|
int platform_adc_update_sequence();
|
|
|
|
int platform_adc_start_sequence();
|
Fairly large number of changes in here to make adc work with lua's provided
buf.c.
The smoothing buffer is still kept separate from the main buffering system,
but as samples come in via interrupt, they are placed into a "standard" elua
buf. The size of this buf is configured according to whether one is grabbing
a bunch of samples rapidly (burst), or singly in order to accommodate the
expected number of incoming samples. If smoothing is enabled, incoming
samples are claimed until the smoothing buffer is full, and then remaining
samples are left in the main buffer until they are collected. This means that
whether one is collecting single samples or samples at burst rate, and
smoothing is enabled, the filter will only be providing samples that have
enough history.
Added a function to manually flush both smoothing and main buffers.
This would be useful if you know your state has changed and you only want
fresh samples that are going to be collected after a flush.
Also, a lot of functionality moved into elua_adc.c and common.c
(boundaries for what belongs where, might be evaluated), reducing the number
of platform.c specific functions dramatically.
Basic functionality seems to be working, but some more testing should be done.
Also, given that there's now a dynamic buffer behind everything, a shift in
the way sampling is handled could be done:
sample and burst functions could be made to be non-blocking, and to never
return anything except for errors.
a separate getsamples function could be used for removing samples collected by
either function from the buffer.
Suggestions are welcome as it would be nice to keep usage paradigms stable
after the 0.6 release.
2009-02-16 00:53:00 +00:00
|
|
|
void platform_adc_stop( unsigned id );
|
2011-10-05 16:08:45 +02:00
|
|
|
u32 platform_adc_set_clock( unsigned id, u32 frequency);
|
|
|
|
int platform_adc_check_timer_id( unsigned id, unsigned timer_id );
|
2009-01-27 20:49:45 +00:00
|
|
|
|
Fairly large number of changes in here to make adc work with lua's provided
buf.c.
The smoothing buffer is still kept separate from the main buffering system,
but as samples come in via interrupt, they are placed into a "standard" elua
buf. The size of this buf is configured according to whether one is grabbing
a bunch of samples rapidly (burst), or singly in order to accommodate the
expected number of incoming samples. If smoothing is enabled, incoming
samples are claimed until the smoothing buffer is full, and then remaining
samples are left in the main buffer until they are collected. This means that
whether one is collecting single samples or samples at burst rate, and
smoothing is enabled, the filter will only be providing samples that have
enough history.
Added a function to manually flush both smoothing and main buffers.
This would be useful if you know your state has changed and you only want
fresh samples that are going to be collected after a flush.
Also, a lot of functionality moved into elua_adc.c and common.c
(boundaries for what belongs where, might be evaluated), reducing the number
of platform.c specific functions dramatically.
Basic functionality seems to be working, but some more testing should be done.
Also, given that there's now a dynamic buffer behind everything, a shift in
the way sampling is handled could be done:
sample and burst functions could be made to be non-blocking, and to never
return anything except for errors.
a separate getsamples function could be used for removing samples collected by
either function from the buffer.
Suggestions are welcome as it would be nice to keep usage paradigms stable
after the 0.6 release.
2009-02-16 00:53:00 +00:00
|
|
|
// ADC Common Functions
|
2011-07-23 20:04:32 +02:00
|
|
|
int platform_adc_exists( unsigned id );
|
|
|
|
u32 platform_adc_get_maxval( unsigned id );
|
|
|
|
u32 platform_adc_set_smoothing( unsigned id, u32 length );
|
|
|
|
void platform_adc_set_blocking( unsigned id, u32 mode );
|
|
|
|
void platform_adc_set_freerunning( unsigned id, u32 mode );
|
|
|
|
u32 platform_adc_is_done( unsigned id );
|
|
|
|
void platform_adc_set_timer( unsigned id, u32 timer );
|
2009-01-21 23:40:34 +00:00
|
|
|
|
2010-07-21 20:21:55 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// I2C platform interface
|
|
|
|
|
|
|
|
// I2C speed
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_I2C_SPEED_SLOW = 100000,
|
|
|
|
PLATFORM_I2C_SPEED_FAST = 400000
|
|
|
|
};
|
|
|
|
|
|
|
|
// I2C direction
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PLATFORM_I2C_DIRECTION_TRANSMITTER,
|
|
|
|
PLATFORM_I2C_DIRECTION_RECEIVER
|
|
|
|
};
|
|
|
|
|
|
|
|
int platform_i2c_exists( unsigned id );
|
|
|
|
u32 platform_i2c_setup( unsigned id, u32 speed );
|
|
|
|
void platform_i2c_send_start( unsigned id );
|
|
|
|
void platform_i2c_send_stop( unsigned id );
|
|
|
|
int platform_i2c_send_address( unsigned id, u16 address, int direction );
|
|
|
|
int platform_i2c_send_byte( unsigned id, u8 data );
|
|
|
|
int platform_i2c_recv_byte( unsigned id, int ack );
|
|
|
|
|
2008-09-18 20:22:15 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// Ethernet specific functions
|
|
|
|
|
|
|
|
void platform_eth_send_packet( const void* src, u32 size );
|
|
|
|
u32 platform_eth_get_packet_nb( void* buf, u32 maxlen );
|
|
|
|
void platform_eth_force_interrupt();
|
|
|
|
u32 platform_eth_get_elapsed_time();
|
|
|
|
|
2008-07-29 11:08:54 +00:00
|
|
|
// *****************************************************************************
|
|
|
|
// Allocator support
|
|
|
|
|
2008-08-13 13:42:57 +00:00
|
|
|
void* platform_get_first_free_ram( unsigned id );
|
|
|
|
void* platform_get_last_free_ram( unsigned id );
|
2008-07-29 11:08:54 +00:00
|
|
|
|
|
|
|
#endif
|