koreio.c File Reference

This module provides useful API to use a KoreIO from a KoreBot program. More...

Include dependency graph for koreio.c:

Go to the source code of this file.

Functions

void kio_GetFWVersion (knet_dev_t *dev, unsigned int *version)
int kio_ReadAnalog (knet_dev_t *dev, unsigned int an, uint16_t *value, uint32_t *time)
int kio_ReadCAN (knet_dev_t *dev, uint32_t *id, char *len, uint32_t *can_data1, uint32_t *can_data2, char *can_status, uint32_t *time)
int kio_SendCAN (knet_dev_t *dev, uint32_t id, uint32_t can_data1, uint32_t can_data2, char len, char can_status)
int kio_SetANValue (knet_dev_t *dev, unsigned int an, unsigned int value)
int kio_ConfigIO (knet_dev_t *dev, unsigned io, unsigned config)
int kio_ReadIO (knet_dev_t *dev, unsigned int io)
int kio_SetIO (knet_dev_t *dev, unsigned int io)
int kio_ChangeLed (knet_dev_t *dev, unsigned state)
int kio_ChangeIO (knet_dev_t *dev, unsigned int io)
int kio_ClearIO (knet_dev_t *dev, unsigned int io)
int kio_ChangePWM_ratio (knet_dev_t *dev, unsigned int io, unsigned int ratio)
int kio_ChangePWM_freq (knet_dev_t *dev, uint16_t freq)
int kio_ChangePW (knet_dev_t *dev, unsigned int io)
int kio_SetPW (knet_dev_t *dev, unsigned int io)
int kio_ClearPW (knet_dev_t *dev, unsigned int io)
int kio_Timer (knet_dev_t *dev, unsigned action)
void kio_i2c_StartScan (knet_dev_t *dev)
int kio_i2c_ListScan (knet_dev_t *dev, char *list)
void kio_i2c_StartRead (knet_dev_t *dev, char device, char reg, char n_read)
int kio_i2c_ReturnRead (knet_dev_t *dev, char n_read, uint32_t *values)
int kio_i2c_Write (knet_dev_t *dev, char device, char reg, char txdata)


Detailed Description

This module provides useful API to use a KoreIO from a KoreBot program.

Support for the KoreIO board.

Author:
Pierre Bureau (K-Team SA) Frédéric Lambercy (K-Team SA)
Note:
Copyright (C) 2004 K-TEAM SA
Bug:
none discovered.
Todo:
nothing.

Definition in file koreio.c.


Function Documentation

int kio_ChangeIO ( knet_dev_t dev,
unsigned int  io 
)

Change the state of a digital IO

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the io to reset (0-15)
Returns:
  • 0 if succesful
  • -1 if the given io is invalid
  • -2 if the given io is not in output mode

Definition at line 406 of file koreio.c.

References KIO_IOChgBase, and knet_write8().

Referenced by changeio(), and main().

Here is the call graph for this function:

int kio_ChangeLed ( knet_dev_t dev,
unsigned  state 
)

Change the state of the LED

Parameters:
dev K-Net Device Descriptor to the KoreIO
state The LED state is 0 to switch it off 1 to switch it on 2 to changed it
Returns:
  • 0 if succesful
  • -1 if the given state is invalid

Definition at line 381 of file koreio.c.

References KIO_IOChgLed, and knet_write8().

Referenced by changeled().

Here is the call graph for this function:

int kio_ChangePW ( knet_dev_t dev,
unsigned int  io 
)

Change the state of a power output

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the power output to set (0-6)
Returns:
  • 0 if succesful
  • -1 if the given pw is invalid

Definition at line 501 of file koreio.c.

References KIO_PWChgBase, and knet_write8().

Referenced by changepw().

Here is the call graph for this function:

int kio_ChangePWM_freq ( knet_dev_t dev,
uint16_t  freq 
)

Change PWM frequency

Parameters:
dev K-Net Device Descriptor to the KoreIo
freq Frequency of the PWM
Returns:
  • 0 if succesful
  • -1 if fail

Definition at line 473 of file koreio.c.

References KIO_FreqBase, and knet_write8().

Referenced by main(), and setfreq().

Here is the call graph for this function:

int kio_ChangePWM_ratio ( knet_dev_t dev,
unsigned int  io,
unsigned int  ratio 
)

Change PWM channel ratio

Parameters:
dev K-Net Device Descriptor to the KoreIo
io the io to modify PWM ratio ratio the ratio value
Returns:
  • 0 if succesful
  • -1 if the given io is invalid

Definition at line 449 of file koreio.c.

References KIO_PWMRatio, and knet_write8().

Referenced by elbow(), finger(), gripper(), main(), motor(), rotate(), sequence(), setratio(), shoulder(), and wrist().

Here is the call graph for this function:

int kio_ClearIO ( knet_dev_t dev,
unsigned int  io 
)

Set a digital IO state to 0

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the io to reset (0-15)
Returns:
  • 0 if succesful
  • -1 if the given io is invalid
  • -2 if the given io is not in output mode

Definition at line 427 of file koreio.c.

References KIO_IOClearBase, and knet_write8().

Referenced by main(), and resetio().

Here is the call graph for this function:

int kio_ClearPW ( knet_dev_t dev,
unsigned int  io 
)

Set a power output state to 0

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the power output to reset (0-6)
Returns:
  • 0 if succesful
  • -1 if the given pw is invalid

Definition at line 543 of file koreio.c.

References KIO_PWClearBase, and knet_write8().

Referenced by main(), and resetpw().

Here is the call graph for this function:

int kio_ConfigIO ( knet_dev_t dev,
unsigned  io,
unsigned  config 
)

Configure a digital IO to be used as an input, output or PWM ouput

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the io to set (0-15)
config the mode to set (0: input) (1: ouput) (2: pwm)
Returns:
  • 0 if succesful
  • -1 if the given io is invalid
  • -2 if the given config is invalid

Definition at line 296 of file koreio.c.

References KIO_IOConfigIn, KIO_IOConfigOut, KIO_IOConfigPwm, and knet_write8().

Referenced by configio(), and main().

Here is the call graph for this function:

void kio_GetFWVersion ( knet_dev_t dev,
unsigned int *  version 
)

This function get the firmware version and revision number.

Parameters:
dev K-Net Device Descriptor to the KoreIO
version A pointer to a variable that will receive the firmware version number.

Definition at line 41 of file koreio.c.

References KIO_FWVersion, and knet_read8().

Referenced by main().

Here is the call graph for this function:

int kio_i2c_ListScan ( knet_dev_t dev,
char *  list 
)

Return the list of answering devices from a scan on the secondary I2C bus. The scan must be started using kio_i2c_StartScan.

Parameters:
dev K-Net Device Descriptor to the KoreIO
list A pointer to an array of characters to store the list. The array must be large enough to store all the addesses (up to 128bytes).
Returns:
the number of answering devices
  • -1 if the given pointer is null
  • -2 in case of knet transfer failure

Definition at line 602 of file koreio.c.

References KIO_I2C_ScanRead, KIO_I2CList, knet_lltransfer(), and knet_read8().

Referenced by listscan().

Here is the call graph for this function:

int kio_i2c_ReturnRead ( knet_dev_t dev,
char  n_read,
uint32_t *  values 
)

return the values of the previous I2C Read bus.

Parameters:
dev K-Net Device Descriptor to the KoreIO
n_read Number of returned values (max 4)
values Pointer to store the returned values
Returns:
  • 0 if succesful
  • -1 if fail

Definition at line 661 of file koreio.c.

References buf, KIO_I2CReturnRead, and knet_lltransfer().

Referenced by readi2c().

Here is the call graph for this function:

void kio_i2c_StartRead ( knet_dev_t dev,
char  device,
char  reg,
char  n_read 
)

Start an register read on the secondary I2C bus.

Parameters:
dev K-Net Device Descriptor to the KoreIO
device Device address
reg Device register address
n_read Number of read (max 4)

Definition at line 632 of file koreio.c.

References KIO_I2CReadBase, and knet_write8().

Referenced by readi2c().

Here is the call graph for this function:

void kio_i2c_StartScan ( knet_dev_t dev  ) 

Start an address scan on the secondary I2C bus.

Parameters:
dev K-Net Device Descriptor to the KoreIO

Definition at line 583 of file koreio.c.

References KIO_I2CScan, and knet_write8().

Referenced by startscan().

Here is the call graph for this function:

int kio_i2c_Write ( knet_dev_t dev,
char  device,
char  reg,
char  txdata 
)

Write on the secondary I2C bus.

Parameters:
dev K-Net Device Descriptor to the KoreIO
device Device address
reg Device register address
txdata Data to write on device
Returns:
  • 0 if succesful
  • -1 if fail

Definition at line 699 of file koreio.c.

References KIO_I2CWriteAddr, KIO_I2CWriteBase, and knet_write8().

Referenced by writei2c().

Here is the call graph for this function:

int kio_ReadAnalog ( knet_dev_t dev,
unsigned int  an,
uint16_t *  value,
uint32_t *  time 
)

Read an Analog input level. The 10 bit value, as well as the corresponding timestamp are returned. The timestamp is given is mS since the last reset of the timer.

Parameters:
dev K-Net Device Descriptor to the KoreIO
an The analog input to read
value Pointer to store the 10bit value from the A/D
time Pointer to store the 32bit value of the timestamp
Returns:
  • 0 if succesful
  • -1 if the given Analog is invalid
  • -2 in case of knet transfer failure

Definition at line 67 of file koreio.c.

References buf, KIO_ANReadBase, and knet_read8().

Referenced by main(), and readad().

Here is the call graph for this function:

int kio_ReadCAN ( knet_dev_t dev,
uint32_t *  id,
char *  len,
uint32_t *  can_data1,
uint32_t *  can_data2,
char *  can_status,
uint32_t *  time 
)

Read the Can message and erase it. Return the number of other Can messages available.

Parameters:
dev K-Net Device Descriptor to the KoreIO
id Pointer to store the 32bit value of the identifier
len Pointer to store the Data length of the message
can_data1 Pointer to store the 4 Bytes high of Data
can_data2 Pointer to store the 4 Bytes low of Data
status Pointer to store the Status bits of the message
time Pointer to store the 4 Bytes of the message timing
Returns:
  • n_mess The number of available messages if succesful
  • -1 if the buffer is empty
  • -2 in case of knet transfer failure

Definition at line 123 of file koreio.c.

References buf, KIO_CANReadBase, KIO_ClearCAN, knet_lltransfer(), and knet_write8().

Referenced by readcan().

Here is the call graph for this function:

int kio_ReadIO ( knet_dev_t dev,
unsigned int  io 
)

Read a digital IO state

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the io to read (0-15)
Returns:
  • 0 if succesful
  • -1 if the given io is invalid
  • -2 if the given io is not in input mode

Definition at line 331 of file koreio.c.

References KIO_IOReadBase, and knet_read8().

Referenced by readio().

Here is the call graph for this function:

int kio_SendCAN ( knet_dev_t dev,
uint32_t  id,
uint32_t  can_data1,
uint32_t  can_data2,
char  len,
char  can_status 
)

Send a CAN message on the CAN bus

Parameters:
dev K-Net Device Descriptor to the KoreIO
id Can identifier on 32 Bits
can_data1 4 Data high
can_data2 4 Data low
len Number of Bytes to send on the Bus
status Set the CAN control bits
Returns:
  • 0 if succesful
  • 1 if fail

Definition at line 195 of file koreio.c.

References KIO_CANWriteBase, KIO_Status, knet_read8(), and knet_write8().

Referenced by can7seg(), and canled().

Here is the call graph for this function:

int kio_SetANValue ( knet_dev_t dev,
unsigned int  an,
unsigned int  value 
)

Change a analog output value

Parameters:
dev K-Net Device Descriptor to the KoreIO
an the output to set (0-7)
value the analog value (0-255)
Returns:
  • 0 if succesful
  • -1 if the given output is invalid

Definition at line 265 of file koreio.c.

References KIO_ANWriteBase, and knet_write8().

Referenced by setad().

Here is the call graph for this function:

int kio_SetIO ( knet_dev_t dev,
unsigned int  io 
)

Set a digital IO state to 1

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the io to set (0-15)
Returns:
  • 0 if succesful
  • -1 if the given io is invalid
  • -2 if the given io is not in output mode

Definition at line 358 of file koreio.c.

References KIO_IOSetBase, and knet_write8().

Referenced by main(), and setio().

Here is the call graph for this function:

int kio_SetPW ( knet_dev_t dev,
unsigned int  io 
)

Set a power output state to 1

Parameters:
dev K-Net Device Descriptor to the KoreIO
io the power output to set (0-6)
Returns:
  • 0 if succesful
  • -1 if the given pw is invalid

Definition at line 522 of file koreio.c.

References KIO_PWSetBase, and knet_write8().

Referenced by main(), and setpw().

Here is the call graph for this function:

int kio_Timer ( knet_dev_t dev,
unsigned  action 
)

Handle the koreio timer for analog measurements timestamp.

Parameters:
dev K-Net Device Descriptor to the KoreIO
action The action to perform with the timer 0: Reset the timer 1: Stop the timer 2: Launch the timer
Returns:
  • 0 if succesful
  • -1 if the given action is invalid

Definition at line 567 of file koreio.c.

References KIO_TimerBase, and knet_write8().

Referenced by timer().

Here is the call graph for this function:


Generated on Wed Dec 15 11:49:29 2010 for KoreBot Library by  doxygen 1.5.5