- Main Page
- Modules
- Data Structures
- Files
- Directories

# ComModule.c File Reference

`#include "ComModule.h"`
`#include <stdlib.h>`
`#include "./motor_led/e_epuck_ports.h"`
`#include "./I2C/e_I2C_protocol.h"`
`#include "./I2C/e_I2C_master_module.h"`

## Defines
#define | COM_MODULE_I2C_ADDR (0x3F<<1)
#define | BUFFER_DATA_LENGTH (COM_MODULE_MAXSIZE + 14)
#define | STATUS_REG_ADDR 0x00
#define | CONFIG_REG_ADDR 0x01
#define | SEND_REG_ADDR 0x02
#define | SOFTATT_REG_ADDR 0x03
#define | OWNGROUP_REG_ADDR 0x04
#define | OWNADDRL_REG_ADDR 0x05
#define | OWNADDRH_REG_ADDR 0x06
#define | SEND_BUFFER_START 0x07
#define | SEND_BUFFER_END (SEND_BUFFER_START + BUFFER_DATA_LENGTH)
#define | REC_BUFFER_START (SEND_BUFFER_END + 1)
#define | REC_BUFFER_END (REC_BUFFER_START + BUFFER_DATA_LENGTH)
#define | AM_MSGTYPE 0x0A
#define | AM_MSGTYPE_IN_PACKET_OFFSET 0x08
#define | ADDRLDATA_IN_PACKET_OFFSET 0x06
#define | ADDRHDATA_IN_PACKET_OFFSET 0x07
#define | TYPEDATA_IN_PACKET_OFFSET 0x08
#define | GROUPDATA_IN_PACKET_OFFSET 0x09
#define | FIRSTDATA_IN_PACKET_OFFSET 0x0A
#define | PACKET_READY_FLAG 0x01
#define | TX_IDLE_FLAG 0x02
#define | PACKET_LOST_FLAG 0x04
#define | TX_SEND_ERROR 0x08
#define | HARDWAREATT_SET_FLAG 0x01
#define | RADIO_ENABLED_FLAG 0x80
#define | REQUEST_TO_SEND_FLAG 0x01
## Functions
unsigned char | ReadRegister (unsigned char registeraddr)
void | WriteRegister (unsigned char registeraddr, unsigned char value)
void | InitComModule (unsigned char owngroup, unsigned int ownaddress, unsigned char hardwareattenuatormode, unsigned char softwareattenuatorvalue)
int | IsModulePlugged ()
void | SetRadioEnabledState (unsigned char mode)
void | SetHardwareAttenuator (unsigned char attenuatormode)
void | SetSoftwareAttenuator (unsigned char attenuatorvalue)
void | SetOwnGroup (unsigned char owngroup)
void | SetOwnAddress (unsigned int ownaddress)
unsigned char | GetHardwareAttenuator ()
unsigned char | GetRadioEnabledState ()
unsigned char | GetSoftwareAttenuator ()
unsigned char | GetOwnGroup ()
unsigned int | GetOwnAddress ()
unsigned char | GetStatus ()
int | SendPacket (unsigned char destinationgroup, unsigned int destinationaddress, unsigned char *packet, int packetsize)
int | IsPacketReady (unsigned char *packet, int *packetsize)

## Define Documentation

#define ADDRHDATA_IN_PACKET_OFFSET 0x07

#define ADDRLDATA_IN_PACKET_OFFSET 0x06

#define AM_MSGTYPE 0x0A

#define AM_MSGTYPE_IN_PACKET_OFFSET 0x08

#define BUFFER_DATA_LENGTH (COM_MODULE_MAXSIZE + 14)

#define COM_MODULE_I2C_ADDR (0x3F<<1)

#define CONFIG_REG_ADDR 0x01

#define FIRSTDATA_IN_PACKET_OFFSET 0x0A

#define GROUPDATA_IN_PACKET_OFFSET 0x09

#define HARDWAREATT_SET_FLAG 0x01

#define OWNADDRH_REG_ADDR 0x06

#define OWNADDRL_REG_ADDR 0x05

#define OWNGROUP_REG_ADDR 0x04

#define PACKET_LOST_FLAG 0x04

#define PACKET_READY_FLAG 0x01

#define RADIO_ENABLED_FLAG 0x80

#define REC_BUFFER_END (REC_BUFFER_START + BUFFER_DATA_LENGTH)

#define REC_BUFFER_START (SEND_BUFFER_END + 1)

#define REQUEST_TO_SEND_FLAG 0x01

#define SEND_BUFFER_END (SEND_BUFFER_START + BUFFER_DATA_LENGTH)

#define SEND_BUFFER_START 0x07

#define SEND_REG_ADDR 0x02

#define SOFTATT_REG_ADDR 0x03

#define STATUS_REG_ADDR 0x00

#define TX_IDLE_FLAG 0x02

#define TX_SEND_ERROR 0x08

#define TYPEDATA_IN_PACKET_OFFSET 0x08

## Function Documentation

unsigned char GetHardwareAttenuator | ( |  | ) |

unsigned int GetOwnAddress | ( |  | ) |

unsigned char GetOwnGroup | ( |  | ) |

unsigned char GetRadioEnabledState | ( |  | ) |

unsigned char GetSoftwareAttenuator | ( |  | ) |

unsigned char GetStatus | ( |  | ) |

void InitComModule | ( | unsigned char | owngroup,
|  | unsigned int | ownaddress,
|  | unsigned char | hardwareattenuatormode,
|  | unsigned char | softwareattenuatorvalue |
| ) |  |  |

int IsModulePlugged | ( |  | ) |

int IsPacketReady | ( | unsigned char * | packet,
|  | int * | packetsize |
| ) |  |  |

unsigned char ReadRegister | ( | unsigned char | registeraddr | ) |

int SendPacket | ( | unsigned char | destinationgroup,
|  | unsigned int | destinationaddress,
|  | unsigned char * | packet,
|  | int | packetsize |
| ) |  |  |

void SetHardwareAttenuator | ( | unsigned char | attenuatormode | ) |

void SetOwnAddress | ( | unsigned int | ownaddress | ) |

void SetOwnGroup | ( | unsigned char | owngroup | ) |

void SetRadioEnabledState | ( | unsigned char | mode | ) |

void SetSoftwareAttenuator | ( | unsigned char | attenuatorvalue | ) |

void WriteRegister | ( | unsigned char | registeraddr,
|  | unsigned char | value |
| ) |  |  |