Commit df0e694a authored by Peter Zumbruch's avatar Peter Zumbruch
Browse files

moved twi specific definitions from api.c/h into twi code

git-svn-id: https://subversion.gsi.de/epics/trunk/hadcon/API-Slave@392 50339f28-a4cd-11e1-ab1f-8360dde1fe65
parent 6d008b77
......@@ -64,6 +64,32 @@
#define TWI_NO_STATE 0xF8 // No relevant state information available; TWINT = �0�
#define TWI_BUS_ERROR 0x00 // Bus error due to an illegal START or STOP condition
static const char tw00[] PROGMEM = "Error Initiating TWI interface";
static const char tw01[] PROGMEM = "Could not start TWI Bus for WRITE";
static const char tw02[] PROGMEM = "Could not start TWI Bus for READ";
static const char tw03[] PROGMEM = "unknown command";
static const char tw04[] PROGMEM = "address_is_too_long";
static const char tw05[] PROGMEM = "data length is too long";
static const char tw06[] PROGMEM = "data 0 is too long";
static const char tw07[] PROGMEM = "data 1 is too long";
static const char tw08[] PROGMEM = "data 2 is too long";
static const char tw09[] PROGMEM = "data 3 is too long";
static const char tw10[] PROGMEM = "data 4 is too long";
static const char tw11[] PROGMEM = "data 5 is too long";
static const char tw12[] PROGMEM = "data 6 is too long";
static const char tw13[] PROGMEM = "data 7 is too long";
static const char tw14[] PROGMEM = "failed writing TWI_Bus";
static const char tw15[] PROGMEM = "failed reading TWI_Bus";
static const char tw16[] PROGMEM = "too few (numeric) arguments";
static const char tw17[] PROGMEM = "wrong length or number of data bytes";
const char *twi_error[] PROGMEM = { tw00, tw01, tw02, tw03, tw04,
tw05, tw06, tw07, tw08, tw09,
tw10, tw11, tw12, tw13, tw14,
tw15, tw16, tw17 };
/* array for defined can error number*/
const uint8_t twi_error_number[] = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60};
void twiMaster(struct uartStruct *ptr_uartStruct)
{
int status = -1;
......
......@@ -8,11 +8,36 @@
#warning READ/WRITE mins differ!
#define TWIS_MIN_NARGS 3
extern const char *twi_error[] PROGMEM;
enum te_index
{
TWI_ERROR_Error_in_initiating_TWI_interface = 0,
TWI_ERROR_Could_not_start_TWI_Bus_for_WRITE,
TWI_ERROR_Could_not_start_TWI_Bus_for_READ,
TWI_ERROR_unknown_command,
TWI_ERROR_address_is_too_long,
TWI_ERROR_data_length_is_too_long,
TWI_ERROR_data_0_is_too_long,
TWI_ERROR_data_1_is_too_long,
TWI_ERROR_data_2_is_too_long,
TWI_ERROR_data_3_is_too_long,
TWI_ERROR_data_4_is_too_long,
TWI_ERROR_data_5_is_too_long,
TWI_ERROR_data_6_is_too_long,
TWI_ERROR_data_7_is_too_long,
TWI_ERROR_failed_writing_TWI_Bus,
TWI_ERROR_failed_reading_TWI_Bus,
TWI_ERROR_too_few_numeric_arguments,
TWI_ERROR_wrong_length_or_number_of_data_bytes,
TWI_ERROR_MAXIMUM_INDEX
};
/* Elements necessary for TWI communication */
#define TWI_MAX_DATA_ELEMENTS 8 // Maximum data elements in one transfer
extern uint16_t twi_data[TWI_MAX_DATA_ELEMENTS]; // Data array
extern uint8_t twi_bytes_to_transceive; // How much bytes to send/receive.
/* Function-declaration for writing/reading TWI */
uint8_t Twim_Write_Data(uint8_t Address, uint8_t twi_bytes_to_transceive, uint16_t twi_data[TWI_MAX_DATA_ELEMENTS]);
uint8_t Twim_Read_Data(uint8_t Address, uint8_t twi_bytes_to_transceive, uint16_t twi_data[TWI_MAX_DATA_ELEMENTS]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment