|
Carga Dinâmica
0.1
Sistemas de Instrumentação Electrónica
|
configuratoin for i2c More...
#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <xc.h>#include "uart.h"#include "confHardware.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 | |
configuratoin for i2c
| int16_t getTemperatureC | ( | int16_t * | temperature | ) |
Reading function for a temperature sensor.
| *temperature | registor to save temperature vaule. |
| void i2c1_init | ( | uint32_t | PBCLK, |
| uint32_t | clock_freq | ||
| ) |
this function is to initialization i2c
| PBCLK | frequency of pic work. |
| clock_freq | frequency of i2c clock |
| int8_t i2c1_receive | ( | int8_t | ack_bit | ) |
this function is to initialization i2c
| PBCLK | frequency of pic work. |
| 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.
| value | value to send |
| void i2c1_stop | ( | void | ) |
stop condition to work i2c