Carga Dinâmica  0.1
Sistemas de Instrumentação Electrónica
i2c.h File Reference

configuratoin for i2c More...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <xc.h>
#include "uart.h"
#include "confHardware.h"
Include dependency graph for i2c.h:

Go to the source code of this file.

Macros

#define READ   1
 
#define WRITE   0
 
#define ACK   0
 
#define NACK   1
 
#define ADDR_WR   ((SENS_ADDRESS << 1) | WRITE)
 
#define ADDR_RD   ((SENS_ADDRESS << 1) | READ)
 
#define SENS_ADDRESS   tempAdddress
 
#define I2C_CLK_FREQ   100000
 
#define RTR   0
 

Functions

void i2c1_init (uint32_t PBCLK, uint32_t clock_freq)
 this function is to initialization i2c More...
 
void i2c1_start (void)
 start condition to work i2c
 
void i2c1_stop (void)
 
int16_t i2c1_send (uint8_t value)
 This function should implement the following sequence of actions: More...
 
int8_t i2c1_receive (int8_t ack_bit)
 this function is to initialization i2c More...
 
int16_t getTemperatureC (int16_t *temperature)
 Reading function for a temperature sensor. More...
 
void debugTemp ()
 function use for temperature sensor printing in serial
 

Detailed Description

configuratoin for i2c

Function Documentation

◆ getTemperatureC()

int16_t getTemperatureC ( int16_t *  temperature)

Reading function for a temperature sensor.

Parameters
*temperatureregistor to save temperature vaule.
Returns
List (if feasible) and describe the return values of the function.
  • 1 Indicates an error occurred
  • 0 Indicates an error did not occur

◆ i2c1_init()

void i2c1_init ( uint32_t  PBCLK,
uint32_t  clock_freq 
)

this function is to initialization i2c

Parameters
PBCLKfrequency of pic work.
clock_freqfrequency of i2c clock

◆ i2c1_receive()

int8_t i2c1_receive ( int8_t  ack_bit)

this function is to initialization i2c

Parameters
PBCLKfrequency of pic work.

◆ i2c1_send()

int16_t i2c1_send ( uint8_t  value)

This function should implement the following sequence of actions:

1) copy to the I2C1TRN register the byte to be transmitted;

2) wait for the byte is transmitted and acknowledgment is received.

Parameters
valuevalue to send
Returns
Receiver acknowledges the receipt

◆ i2c1_stop()

void i2c1_stop ( void  )

stop condition to work i2c