Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 201 → Rev 202

/PIC Stuff/PICX_16F1829_BLE_IMU/I2C.c
0,0 → 1,551
#include <xc.h>
#include "main.h"
#include "I2C.h"
 
static I2C_DATA *data_ptr;
 
// Set up the data structures for the base_I2C.code
// Should be called once before any i2c routines are called
void I2C_Init(I2C_DATA *data) {
data_ptr = data;
 
I2C_CLK_TRIS = 1;
I2C_DAT_TRIS = 1;
 
data_ptr->buffer_in_len = 0;
data_ptr->buffer_in_len_tmp = 0;
data_ptr->buffer_in_read_ind = 0;
data_ptr->buffer_in_write_ind = 0;
 
data_ptr->buffer_out_ind = 0;
data_ptr->buffer_out_len = 0;
 
data_ptr->operating_mode = 0;
data_ptr->operating_state = I2C_IDLE;
data_ptr->return_status = 0;
 
data_ptr->slave_in_last_byte = 0;
data_ptr->slave_sending_data = 0;
 
data_ptr->master_dest_addr = 0;
data_ptr->master_status = I2C_MASTER_IDLE;
 
// Enable I2C interrupt
PIE1bits.SSP1IE = 1;
}
 
// Setup the PIC to operate as a master.
void I2C_Configure_Master(char speed) {
data_ptr->operating_mode = I2C_MODE_MASTER;
 
SSP1STAT = 0x0;
SSP1CON1 = 0x0;
SSP1CON2 = 0x0;
SSP1CON3 = 0x0;
SSP1CON1bits.SSPM = 0x8; // I2C Master Mode
if (speed) {
SSP1ADD = 0x4F; // Operate at 100KHz (32MHz)
} else {
SSP1ADD = 0x13; // Operate at 400KHz (32MHz)
}
SSP1STATbits.SMP = 1; // Disable Slew Rate Control
SSP1CON3bits.PCIE = 1; // Stop condition interrupt enable
SSP1CON3bits.SCIE = 1; // Start condition interrupt enable
SSP1CON1bits.SSPEN = 1; // Enable MSSP Module
}
 
// Sends length number of bytes in msg to specified address (no R/W bit)
void I2C_Master_Send(char address, char length, char *msg) {
char i;
if (length == 0)
return;
 
// Copy message to send into buffer and save length/address
for (i = 0; i < length; i++) {
data_ptr->buffer_in[i] = msg[i];
}
data_ptr->buffer_in_len = length;
data_ptr->master_dest_addr = address;
data_ptr->buffer_in_read_ind = 0;
data_ptr->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
data_ptr->operating_state = I2C_SEND_ADDR;
data_ptr->master_status = I2C_MASTER_SEND;
 
// Generate start condition
SSP1CON2bits.SEN = 1;
}
 
// Reads length number of bytes from address (no R/W bit)
void I2C_Master_Recv(char address, char length) {
if (length == 0)
return;
 
// Save length and address to get data from
data_ptr->buffer_in_len = length;
data_ptr->master_dest_addr = address;
data_ptr->buffer_in_read_ind = 0;
data_ptr->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
data_ptr->operating_state = I2C_SEND_ADDR;
data_ptr->master_status = I2C_MASTER_RECV;
 
// Generate start condition
SSP1CON2bits.SEN = 1;
}
 
// Writes msg to address then reads length number of bytes from address
void I2C_Master_Restart(char address, char msg, char length) {
char c;
if (length == 0) {
c = msg;
I2C_Master_Send(address, 1, &c);
return;
}
 
// Save length and address to get data from
data_ptr->buffer_in[0] = msg;
data_ptr->buffer_in_len = length;
data_ptr->master_dest_addr = address;
data_ptr->buffer_in_read_ind = 0;
data_ptr->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
data_ptr->operating_state = I2C_SEND_ADDR;
data_ptr->master_status = I2C_MASTER_RESTART;
 
// Generate start condition
SSP1CON2bits.SEN = 1;
}
 
// Setup the PIC to operate as a slave. The address must not include the R/W bit
void I2C_Configure_Slave(char addr) {
data_ptr->operating_mode = I2C_MODE_SLAVE;
 
SSP1ADD = addr << 1; // Set the slave address
 
SSP1STAT = 0x0;
SSP1CON1 = 0x0;
SSP1CON2 = 0x0;
SSP1CON3 = 0x0;
SSP1CON1bits.SSPM = 0xE; // Enable Slave 7-bit w/ start/stop interrupts
SSP1STATbits.SMP = 1; // Slew Off
SSP1CON2bits.SEN = 1; // Enable clock-stretching
SSP1CON1bits.SSPEN = 1; // Enable MSSP Module
}
 
void I2C_Interrupt_Handler() {
// Call interrupt depending on which mode we are operating in
if (data_ptr->operating_mode == I2C_MODE_MASTER) {
I2C_Interrupt_Master();
} else if (data_ptr->operating_mode == I2C_MODE_SLAVE) {
I2C_Interrupt_Slave();
}
}
 
// An internal subroutine used in the master version of the i2c_interrupt_handler
void I2C_Interrupt_Master() {
// If we are in the middle of sending data
if (data_ptr->master_status == I2C_MASTER_SEND) {
switch (data_ptr->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send the address with read bit set
data_ptr->operating_state = I2C_CHECK_ACK_SEND;
SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x0;
break;
case I2C_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!SSP1CON2bits.ACKSTAT) {
// If an ACK is received, send next byte of data
if (data_ptr->buffer_in_read_ind < data_ptr->buffer_in_len) {
SSP1BUF = data_ptr->buffer_in[data_ptr->buffer_in_read_ind];
data_ptr->buffer_in_read_ind++;
} else {
// If no more data is to be sent, send stop bit
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_SEND_OK;
}
} else {
// If a NACK is received, stop transmission and send error
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_SEND_FAIL;
}
break;
}
// If we are in the middle of receiving data
} else if (data_ptr->master_status == I2C_MASTER_RECV) {
switch (data_ptr->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send address with write bit set
data_ptr->operating_state = I2C_CHECK_ACK_RECV;
SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x1;
break;
case I2C_CHECK_ACK_RECV:
// Check if ACK is received
if (!SSP1CON2bits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
data_ptr->operating_state = I2C_RCV_DATA;
SSP1CON2bits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_RECV_FAIL;
}
break;
case I2C_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
data_ptr->buffer_in[data_ptr->buffer_in_write_ind] = SSP1BUF;
data_ptr->buffer_in_write_ind++;
if (data_ptr->buffer_in_write_ind < data_ptr->buffer_in_len) {
// If we still need to read, send an ACK to the slave
data_ptr->operating_state = I2C_REQ_DATA;
SSP1CON2bits.ACKDT = 0; // ACK
SSP1CON2bits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
data_ptr->operating_state = I2C_SEND_STOP;
SSP1CON2bits.ACKDT = 1; // NACK
SSP1CON2bits.ACKEN = 1;
}
break;
case I2C_REQ_DATA:
// Set module to receive one byte of data
data_ptr->operating_state = I2C_RCV_DATA;
SSP1CON2bits.RCEN = 1;
break;
case I2C_SEND_STOP:
// Send the stop bit and copy message to send to Main()
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_RECV_OK;
break;
}
} else if (data_ptr->master_status == I2C_MASTER_RESTART) {
switch (data_ptr->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send the address with read bit set
data_ptr->operating_state = I2C_CHECK_ACK_SEND;
SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x0;
break;
case I2C_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!SSP1CON2bits.ACKSTAT) {
// If an ACK is received, send first byte of data
SSP1BUF = data_ptr->buffer_in[0];
data_ptr->operating_state = I2C_CHECK_ACK_RESTART;
} else {
// If a NACK is received, stop transmission and send error
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_SEND_FAIL;
}
break;
case I2C_CHECK_ACK_RESTART:
if (!SSP1CON2bits.ACKSTAT) {
SSP1CON2bits.RSEN = 1;
data_ptr->operating_state = I2C_SEND_ADDR_2;
} else {
// If a NACK is received, stop transmission and send error
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_SEND_FAIL;
}
break;
case I2C_SEND_ADDR_2:
// Send the address with read bit set
data_ptr->operating_state = I2C_CHECK_ACK_RECV;
SSP1BUF = (data_ptr->master_dest_addr << 1) | 0x1;
break;
case I2C_CHECK_ACK_RECV:
// Check if ACK is received
if (!SSP1CON2bits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
data_ptr->operating_state = I2C_RCV_DATA;
SSP1CON2bits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_RECV_FAIL;
}
break;
case I2C_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
data_ptr->buffer_in[data_ptr->buffer_in_write_ind] = SSP1BUF;
data_ptr->buffer_in_write_ind++;
if (data_ptr->buffer_in_write_ind < data_ptr->buffer_in_len) {
// If we still need to read, send an ACK to the slave
data_ptr->operating_state = I2C_REQ_DATA;
SSP1CON2bits.ACKDT = 0; // ACK
SSP1CON2bits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
data_ptr->operating_state = I2C_SEND_STOP;
SSP1CON2bits.ACKDT = 1; // NACK
SSP1CON2bits.ACKEN = 1;
}
break;
case I2C_REQ_DATA:
// Set module to receive one byte of data
data_ptr->operating_state = I2C_RCV_DATA;
SSP1CON2bits.RCEN = 1;
break;
case I2C_SEND_STOP:
// Send the stop bit and copy message to send to Main()
data_ptr->operating_state = I2C_IDLE;
SSP1CON2bits.PEN = 1;
data_ptr->master_status = I2C_MASTER_IDLE;
data_ptr->return_status = I2C_RECV_OK;
break;
}
}
}
 
void I2C_Interrupt_Slave() {
char received_data;
char data_read_from_buffer = 0;
char data_written_to_buffer = 0;
char overrun_error = 0;
 
// Clear SSPOV (overflow bit)
if (SSP1CON1bits.SSPOV == 1) {
SSP1CON1bits.SSPOV = 0;
// We failed to read the buffer in time, so we know we
// can't properly receive this message, just put us in the
// a state where we are looking for a new message
data_ptr->operating_state = I2C_IDLE;
overrun_error = 1;
data_ptr->return_status = I2C_ERR_OVERRUN;
}
 
// Read SPPxBUF if it is full
if (SSP1STATbits.BF == 1) {
received_data = SSP1BUF;
data_read_from_buffer = 1;
}
 
if (!overrun_error) {
switch (data_ptr->operating_state) {
case I2C_IDLE:
{
// Ignore anything except a start
if (SSP1STATbits.S == 1) {
data_ptr->buffer_in_len_tmp = 0;
data_ptr->operating_state = I2C_STARTED;
// if (data_read_from_buffer) {
// if (SSPSTATbits.D_A == 1) {
// DBG_PRINT_I2C("I2C Start: (ERROR) no address recieved\r\n");
// // This is bad because we got data and we wanted an address
// data_ptr->operating_state = I2C_IDLE;
// data_ptr->return_status = I2C_ERR_NOADDR;
// } else {
// // Determine if we are sending or receiving data
// if (SSPSTATbits.R_W == 1) {
// data_ptr->operating_state = I2C_SEND_DATA;
// } else {
// data_ptr->operating_state = I2C_RCV_DATA;
// }
// }
// } else {
// data_ptr->operating_state = I2C_STARTED;
// }
}
break;
}
case I2C_STARTED:
{
// In this case, we expect either an address or a stop bit
if (SSP1STATbits.P == 1) {
// Return to idle mode
data_ptr->operating_state = I2C_IDLE;
} else if (data_read_from_buffer) {
if (SSP1STATbits.D_nA == 0) {
// Address received
if (SSP1STATbits.R_nW == 0) {
// Slave write mode
data_ptr->operating_state = I2C_RCV_DATA;
} else {
// Slave read mode
data_ptr->operating_state = I2C_SEND_DATA;
// Process the first byte immediatly if sending data
goto send;
}
} else {
data_ptr->operating_state = I2C_IDLE;
data_ptr->return_status = I2C_ERR_NODATA;
}
}
break;
}
send:
case I2C_SEND_DATA:
{
if (!data_ptr->slave_sending_data) {
// If we are not currently sending data, figure out what to reply with
if (I2C_Process_Send(data_ptr->slave_in_last_byte)) {
// Data exists to be returned, send first byte
SSP1BUF = data_ptr->buffer_out[0];
data_ptr->buffer_out_ind = 1;
data_ptr->slave_sending_data = 1;
data_written_to_buffer = 1;
} else {
// Unknown request
data_ptr->slave_sending_data = 0;
data_ptr->operating_state = I2C_IDLE;
}
} else {
// Sending remaining data back to master
if (data_ptr->buffer_out_ind < data_ptr->buffer_out_len) {
SSP1BUF = data_ptr->buffer_out[data_ptr->buffer_out_ind];
data_ptr->buffer_out_ind++;
data_written_to_buffer = 1;
} else {
// Nothing left to send
data_ptr->slave_sending_data = 0;
data_ptr->operating_state = I2C_IDLE;
}
}
break;
}
case I2C_RCV_DATA:
{
// We expect either data or a stop bit or a (if a restart, an addr)
if (SSP1STATbits.P == 1) {
// Stop bit detected, we need to check to see if we also read data
if (data_read_from_buffer) {
if (SSP1STATbits.D_nA == 1) {
// Data received with stop bit
// TODO: Handle I2C buffer overflow
data_ptr->buffer_in[data_ptr->buffer_in_write_ind] = received_data;
if (data_ptr->buffer_in_write_ind == I2C_BUFFER_SIZE-1) {
data_ptr->buffer_in_write_ind = 0;
} else {
data_ptr->buffer_in_write_ind++;
}
data_ptr->buffer_in_len_tmp++;
// Save the last byte received
data_ptr->slave_in_last_byte = received_data;
data_ptr->return_status = I2C_DATA_AVAL;
} else {
data_ptr->operating_state = I2C_IDLE;
data_ptr->return_status = I2C_ERR_NODATA;
}
}
data_ptr->buffer_in_len += data_ptr->buffer_in_len_tmp;
data_ptr->operating_state = I2C_IDLE;
} else if (data_read_from_buffer) {
if (SSP1STATbits.D_nA == 1) {
// Data received
data_ptr->buffer_in[data_ptr->buffer_in_write_ind] = received_data;
if (data_ptr->buffer_in_write_ind == I2C_BUFFER_SIZE-1) {
data_ptr->buffer_in_write_ind = 0;
} else {
data_ptr->buffer_in_write_ind++;
}
data_ptr->buffer_in_len_tmp++;
// Save the last byte received
data_ptr->slave_in_last_byte = received_data;
data_ptr->return_status = I2C_DATA_AVAL;
} else {
// Restart bit detected
if (SSP1STATbits.R_nW == 1) {
data_ptr->buffer_in_len += data_ptr->buffer_in_len_tmp;
data_ptr->operating_state = I2C_SEND_DATA;
// Process the first byte immediatly if sending data
goto send;
} else {
// Bad to recv an address again, we aren't ready
data_ptr->operating_state = I2C_IDLE;
data_ptr->return_status = I2C_ERR_NODATA;
}
}
}
break;
}
}
}
 
// Release the clock stretching bit (if we should)
if (data_read_from_buffer || data_written_to_buffer) {
// Release the clock
if (SSP1CON1bits.CKP == 0) {
SSP1CON1bits.CKP = 1;
}
}
}
 
/* Returns 0 if I2C module is currently busy, otherwise returns status code */
char I2C_Get_Status() {
if (data_ptr->operating_mode == I2C_MODE_MASTER) {
if (data_ptr->master_status != I2C_MASTER_IDLE || data_ptr->buffer_in_len == 0) {
return 0;
} else {
return data_ptr->return_status;
}
} else {
if (data_ptr->operating_state != I2C_IDLE || data_ptr->buffer_in_len == 0) {
return 0;
} else {
return data_ptr->return_status;
}
}
}
 
char I2C_Buffer_Len() {
return data_ptr->buffer_in_len;
}
 
/* Returns 0 if I2C module is currently busy, otherwise returns buffer length */
char I2C_Read_Buffer(char *buffer) {
char i = 0;
while (data_ptr->buffer_in_len != 0) {
buffer[i] = data_ptr->buffer_in[data_ptr->buffer_in_read_ind];
i++;
if (data_ptr->buffer_in_read_ind == I2C_BUFFER_SIZE-1) {
data_ptr->buffer_in_read_ind = 0;
} else {
data_ptr->buffer_in_read_ind++;
}
data_ptr->buffer_in_len--;
}
return i;
}
 
/* Put data to be returned here */
char I2C_Process_Send(char c) {
char ret = 0;
switch (c) {
case 0xAA:
data_ptr->buffer_out[0] = 'A';
data_ptr->buffer_out_len = 1;
ret = 1;
break;
case 0xBB:
data_ptr->buffer_out[0] = '1';
data_ptr->buffer_out[1] = '2';
data_ptr->buffer_out_len = 2;
ret = 1;
break;
}
return ret;
}
/PIC Stuff/PICX_16F1829_BLE_IMU/I2C.h
0,0 → 1,83
#ifndef I2C_H
#define I2C_H
 
#define I2C_BUFFER_SIZE 20
 
// I2C Operating Speed
#define I2C_400KHZ 0x0
#define I2C_100KHZ 0x1
 
// Operating State
#define I2C_IDLE 0x1
#define I2C_STARTED 0x2
#define I2C_RCV_DATA 0x3
#define I2C_SEND_DATA 0x4
#define I2C_SEND_ADDR 0x5
#define I2C_SEND_ADDR_2 0x6
#define I2C_CHECK_ACK_SEND 0x7
#define I2C_CHECK_ACK_RECV 0x8
#define I2C_CHECK_ACK_RESTART 0x9
#define I2C_REQ_DATA 0xA
#define I2C_SEND_STOP 0xB
#define I2C_SEND_START 0xC
 
// Operating Mode
#define I2C_MODE_SLAVE 0x10
#define I2C_MODE_MASTER 0x11
 
// Master Status
#define I2C_MASTER_SEND 0x20
#define I2C_MASTER_RECV 0x21
#define I2C_MASTER_RESTART 0x22
#define I2C_MASTER_IDLE 0x23
 
// Return Status (Master)
#define I2C_SEND_OK 0x30
#define I2C_SEND_FAIL 0x31
#define I2C_RECV_OK 0x32
#define I2C_RECV_FAIL 0x33
 
// Return Status (Slave)
#define I2C_DATA_AVAL 0x34
#define I2C_ERR_NOADDR 0x35
#define I2C_ERR_OVERRUN 0x36
#define I2C_ERR_NODATA 0x37
 
typedef struct {
char buffer_in[I2C_BUFFER_SIZE];
char buffer_in_len;
char buffer_in_len_tmp;
char buffer_in_read_ind;
char buffer_in_write_ind;
 
char buffer_out[I2C_BUFFER_SIZE];
char buffer_out_len;
char buffer_out_ind;
 
char operating_mode;
char operating_state;
char return_status;
 
char master_dest_addr;
char master_status;
 
char slave_in_last_byte;
char slave_sending_data;
} I2C_DATA;
 
void I2C_Init(I2C_DATA *data);
void I2C_Interrupt_Handler(void);
void I2C_Interrupt_Slave(void);
void I2C_Interrupt_Master(void);
void I2C_Configure_Slave(char);
void I2C_Configure_Master(char speed);
void I2C_Master_Send(char address, char length, char *msg);
void I2C_Master_Recv(char address, char length);
void I2C_Master_Restart(char address, char msg, char length);
char I2C_Get_Status(void);
char I2C_Buffer_Len(void);
char I2C_Read_Buffer(char *buffer);
char I2C_Process_Send(char);
 
#endif /* I2C_H */
 
/PIC Stuff/PICX_16F1829_BLE_IMU/INTERRUPT.c
0,0 → 1,49
#include <xc.h>
#include "main.h"
#include "INTERRUPT.h"
#include "TIMER.h"
#include "UART.h"
#include "I2C.h"
 
void INTERRUPT_Init(void) {
INTCONbits.GIE = 0;
INTCONbits.PEIE = 1;
}
 
void INTERRUPT_Enable(void) {
INTCONbits.GIE = 1;
}
 
void INTERRUPT_Disable(void) {
INTCONbits.GIE = 0;
}
 
void interrupt INTERRUPT_Handler(void) {
// check Timer 1 interrupt flag
if (PIR1bits.TMR1IF) {
TIMER_1_Interrupt_Handler();
PIR1bits.TMR1IF = 0;
}
 
// Check UART RX interrupt flag
if (PIE1bits.RCIE) {
if (PIR1bits.RCIF) {
UART_RX_Interrupt_Handler();
// PIR1bits.RCIF = 0; // RXIF is read-only!
}
}
 
// Check UART TX interrupt flag
if (PIE1bits.TXIE) {
if (PIR1bits.TXIF) {
UART_TX_Interrupt_Handler();
// PIR1bits.TXIF = 0; // TXIF is read-only!
}
}
 
// Check I2C interrupt flag
if (PIR1bits.SSP1IF) {
I2C_Interrupt_Handler();
PIR1bits.SSP1IF = 0;
}
}
/PIC Stuff/PICX_16F1829_BLE_IMU/INTERRUPT.h
0,0 → 1,8
#ifndef INTERRUPT_H
#define INTERRUPT_H
 
void INTERRUPT_Init(void);
void INTERRUPT_Enable(void);
void INTERRUPT_Disable(void);
 
#endif /* INTERRUPT_H */
/PIC Stuff/PICX_16F1829_BLE_IMU/TIMER.c
0,0 → 1,28
#include <xc.h>
#include "main.h"
#include "TIMER.h"
 
void TIMER_1_Init(void) {
T1CONbits.TMR1CS = 2; // Clock source is ext oscillator
T1CONbits.T1CKPS = 0; // Prescale of 1:1
T1CONbits.T1OSCEN = 1; // Dedicated oscillator circuit enabled
T1CONbits.nT1SYNC = 1; // Async external clock input
T1CONbits.TMR1ON = 0; // Timer stopped
T1GCONbits.TMR1GE = 0; // Gate disabled
TMR1 = 0x8000;
 
PIE1bits.TMR1IE = 1; // Timer 1 overflow interrupt
}
 
void TIMER_1_Start(void) {
T1CONbits.TMR1ON = 1; // Start timer
}
 
void TIMER_1_Stop(void) {
T1CONbits.TMR1ON = 0; // Stop timer
}
 
void TIMER_1_Interrupt_Handler(void) {
LED_LAT = ~LED_LAT;
TMR1 = 0x8000;
}
/PIC Stuff/PICX_16F1829_BLE_IMU/TIMER.h
0,0 → 1,9
#ifndef TIMER_H
#define TIMER_H
 
void TIMER_1_Init(void);
void TIMER_1_Start(void);
void TIMER_1_Stop(void);
void TIMER_1_Interrupt_Handler(void);
 
#endif /* TIMER_H */
/PIC Stuff/PICX_16F1829_BLE_IMU/UART.c
0,0 → 1,106
#include <xc.h>
#include "main.h"
#include "UART.h"
 
static UART_DATA *data_ptr;
 
void UART_Init(UART_DATA *data) {
data_ptr = data;
 
APFCON0bits.RXDTSEL = 1; // Change RX from RB5 to RC5
APFCON0bits.TXCKSEL = 1; // Change TX from RB7 to RC4
UART_RX_TRIS = 1;
UART_TX_TRIS = 0;
 
SPBRG = 16; // Set baud rate to 115200 @ 32MHz
BAUDCONbits.BRG16 = 0; // 8-bit baud rate generator
TXSTAbits.BRGH = 1; // High baud rate select
 
TXSTAbits.SYNC = 0; // Async operation
RCSTAbits.CREN = 1; // Enable reception module
TXSTAbits.TXEN = 1; // Enable transmission module
RCSTAbits.SPEN = 1; // Enable EUSART module
 
PIE1bits.RCIE = 1; // UART RX interrupt starts enabled
PIE1bits.TXIE = 0; // UART TX interrupt starts disabled
 
// Initialize local variables
data_ptr->buffer_in_read_ind = 0;
data_ptr->buffer_in_write_ind = 0;
data_ptr->buffer_in_len = 0;
data_ptr->buffer_out_ind = 0;
data_ptr->buffer_out_len = 0;
}
 
void UART_TX_Interrupt_Handler(void) {
// Send more data when transmit buffer is empty
if (data_ptr->buffer_out_ind != data_ptr->buffer_out_len) {
TXREG = data_ptr->buffer_out[data_ptr->buffer_out_ind];
data_ptr->buffer_out_ind++;
} else {
// Stop processing TX interrupts if there is no more data to send
while (!TXSTAbits.TRMT);
PIE1bits.TXIE = 0;
data_ptr->buffer_out_ind = 0;
data_ptr->buffer_out_len = 0;
}
}
 
void UART_RX_Interrupt_Handler(void) {
char c = RCREG;
 
// Read received data into buffer
data_ptr->buffer_in[data_ptr->buffer_in_write_ind] = c;
if (data_ptr->buffer_in_write_ind == UART_BUFFER_SIZE - 1) {
data_ptr->buffer_in_write_ind = 0;
} else {
data_ptr->buffer_in_write_ind++;
}
 
// Increment read counter to keep only the latest data
if (data_ptr->buffer_in_len < UART_BUFFER_SIZE) {
data_ptr->buffer_in_len++;
} else {
if (data_ptr->buffer_in_read_ind == UART_BUFFER_SIZE - 1) {
data_ptr->buffer_in_read_ind = 0;
} else {
data_ptr->buffer_in_read_ind++;
}
}
 
// Reset receiver module on overrun error
if (RCSTAbits.OERR == 1) {
RCSTAbits.CREN = 0;
RCSTAbits.CREN = 1;
}
}
 
void UART_Write(char *data, char length) {
// Ensure that no transmission is currently running
while (PIE1bits.TXIE);
 
data_ptr->buffer_out_len = length;
data_ptr->buffer_out_ind = 0;
for (char i = 0; i < length; i++) {
data_ptr->buffer_out[i] = data[i];
}
 
// Start transmission
PIE1bits.TXIE = 1;
}
 
char UART_Read(char *buffer) {
PIE1bits.RCIE = 0; // Disable receiver interrupt
char length = data_ptr->buffer_in_len;
for (char i = 0; i < length; i++) {
buffer[i] = data_ptr->buffer_in[data_ptr->buffer_in_read_ind];
if (data_ptr->buffer_in_read_ind == UART_BUFFER_SIZE - 1) {
data_ptr->buffer_in_read_ind = 0;
} else {
data_ptr->buffer_in_read_ind++;
}
}
data_ptr->buffer_in_len -= length;
PIE1bits.RCIE = 1; // Re-enable receiver interrupt
return length;
}
/PIC Stuff/PICX_16F1829_BLE_IMU/UART.h
0,0 → 1,25
#ifndef UART_H
#define UART_H
 
#define UART_BUFFER_SIZE 20
 
typedef struct {
char buffer_in[UART_BUFFER_SIZE];
char buffer_in_read_ind;
char buffer_in_write_ind;
char buffer_in_len;
 
char buffer_out[UART_BUFFER_SIZE];
char buffer_out_ind;
char buffer_out_len;
} UART_DATA;
 
void UART_Init(UART_DATA *data);
void UART_Write(char *data, char length);
char UART_Read(char *buffer);
 
void UART_TX_Interrupt_Handler(void);
void UART_RX_Interrupt_Handler(void);
 
#endif /* UART_H */
 
/PIC Stuff/PICX_16F1829_BLE_IMU/funclist
1,3 → 1,29
_main: CODE, 2045 0 3
__initialization: CODE, 2042 0 0
Total: 3
_I2C_Get_Status: CODE, 3846 0 83
_I2C_Interrupt_Master: CODE, 64 0 741
__stringtab: STRING, 2048 0 1
_I2C_Read_Buffer: CODE, 3768 0 78
__stringdata: STRING, 2049 0 27
_INTERRUPT_Init: CODE, 3218 0 3
_UART_Read: CODE, 4012 0 84
_I2C_Interrupt_Slave: CODE, 805 0 571
_INTERRUPT_Handler: CODE, 4 0 58
_I2C_Configure_Master: CODE, 3316 0 38
_I2C_Master_Send: CODE, 1957 0 91
_UART_Init: CODE, 3354 0 52
_main: CODE, 3406 0 53
_Error: CODE, 3570 0 64
_TIMER_1_Init: CODE, 3245 0 18
_I2C_Process_Send: CODE, 3634 0 66
_TIMER_1_Start: CODE, 3215 0 3
_I2C_Interrupt_Handler: CODE, 3282 0 34
_UART_TX_Interrupt_Handler: CODE, 3513 0 57
__initialization: CODE, 3263 0 16
_I2C_Master_Restart: CODE, 3929 0 83
_I2C_Init: CODE, 1862 0 95
_UART_RX_Interrupt_Handler: CODE, 1765 0 97
_Startup_Check: CODE, 1376 0 389
_UART_Write: CODE, 3459 0 54
_TIMER_1_Interrupt_Handler: CODE, 3227 0 18
_memcmp: CODE, 3700 0 68
_INTERRUPT_Enable: CODE, 2 0 2
Total: 2944
/PIC Stuff/PICX_16F1829_BLE_IMU/main.c
1,5 → 1,12
#include <xc.h>
#include <string.h>
#include "main.h"
#include "TIMER.h"
#include "INTERRUPT.h"
#include "UART.h"
#include "I2C.h"
 
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
14,12 → 21,132
 
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON // PLL Enable (4x PLL enabled)
#pragma config PLLEN = ON // PLL Enable (4x PLL disabled)
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
#pragma config LVP = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
// </editor-fold>
 
UART_DATA uart_data;
I2C_DATA i2c_data;
 
void Error(char ID) {
while(1) {
for (char i = 0; i < ID; i++) {
LED_LAT = 1;
__delay_ms(120);
LED_LAT = 0;
__delay_ms(150);
}
__delay_ms(1000);
}
}
 
void Startup_Check(void) {
char buffer[20];
char result, length;
 
BLE_RESET_LAT = 0;
__delay_ms(3000);
BLE_RESET_LAT = 1;
__delay_ms(200);
 
// Check BLE Module
length = UART_Read(buffer);
if (memcmp(buffer, "\r\nBR-LE4.0-S2\r\n", 15)) {
Error(1);
}
UART_Write("AT\r", 3);
__delay_ms(10);
length = UART_Read(buffer);
if (memcmp(buffer, "\r\nOK\r\n", 6)) {
Error(1);
}
 
// Check Battery Gauge
I2C_Master_Restart(ADDRESS_LIPO, 0x0C, 2);
do {
result = I2C_Get_Status();
} while (!result);
if ((result != I2C_SEND_OK) && (result != I2C_RECV_OK)) {
Error(2);
}
length = I2C_Read_Buffer(buffer);
if ((buffer[0] != 0x97) || (buffer[1] != 0x00) || (length != 2)) {
Error(2);
}
// Check Gyroscope
I2C_Master_Restart(ADDRESS_GYRO, 0x0F, 1);
do {
result = I2C_Get_Status();
} while (!result);
if ((result != I2C_SEND_OK) && (result != I2C_RECV_OK)) {
Error(3);
}
length = I2C_Read_Buffer(buffer);
if ((buffer[0] != 0xD4) || (length != 1)) {
Error(3);
}
 
// Check Accelerometer
I2C_Master_Restart(ADDRESS_ACCL, 0x20, 1);
do {
result = I2C_Get_Status();
} while (!result);
if ((result != I2C_SEND_OK) && (result != I2C_RECV_OK)) {
Error(4);
}
length = I2C_Read_Buffer(buffer);
if ((buffer[0] != 0x07) || (length != 1)) {
Error(4);
}
 
// Check Magnometer
I2C_Master_Restart(ADDRESS_MAGN, 0x0A, 1);
do {
result = I2C_Get_Status();
} while (!result);
if ((result != I2C_SEND_OK) && (result != I2C_RECV_OK)) {
Error(4);
}
length = I2C_Read_Buffer(buffer);
if ((buffer[0] != 0x48) || (length != 1)) {
Error(4);
}
}
 
int main() {
 
OSCCON = 0x70; // PLL disabled, 8MHz
ANSELA = 0;
ANSELB = 0;
ANSELC = 0;
 
LED_TRIS = 0;
LED_LAT = 0;
 
BLE_RESET_TRIS = 0;
BLE_RESET_LAT = 0;
 
BLE_SLEEP_TRIS = 0;
BLE_SLEEP_LAT = 0;
 
BLE_MODE_TRIS = 0;
BLE_MODE_LAT = 0;
 
TIMER_1_Init();
UART_Init(&uart_data);
I2C_Init(&i2c_data);
INTERRUPT_Init();
 
I2C_Configure_Master(I2C_100KHZ);
INTERRUPT_Enable();
Startup_Check();
 
TIMER_1_Start();
 
while(1);
}
 
/PIC Stuff/PICX_16F1829_BLE_IMU/main.h
0,0 → 1,58
#ifndef MAIN_H
#define MAIN_H
 
#define UART_RX_TRIS TRISCbits.TRISC5
#define UART_TX_TRIS TRISCbits.TRISC4
#define UART_CTS_TRIS TRISCbits.TRISC3
#define UART_CTS_LAT LATCbits.LATC3
#define UART_RTS_TRIS TRISCbits.TRISC6
#define UART_RTS_LAT LATCbits.LATC6
 
#define I2C_CLK_TRIS TRISBbits.TRISB6
#define I2C_DAT_TRIS TRISBbits.TRISB4
 
#define LED_TRIS TRISCbits.TRISC1
#define LED_LAT LATCbits.LATC1
 
#define BLE_RESET_TRIS TRISCbits.TRISC7
#define BLE_RESET_LAT LATCbits.LATC7
 
#define BLE_SLEEP_TRIS TRISCbits.TRISC2
#define BLE_SLEEP_LAT LATCbits.LATC2
 
#define BLE_MODE_TRIS TRISCbits.TRISC0
#define BLE_MODE_LAT LATCbits.LATC0
 
#define ADDRESS_GYRO 0x6B
#define ADDRESS_ACCL 0x19
#define ADDRESS_MAGN 0x1E
#define ADDRESS_LIPO 0x36
 
#define _XTAL_FREQ 32000000
 
#endif /* MAIN_H */
 
// <editor-fold defaultstate="collapsed" desc="Pinouts">
/*
1/RA3 - MCLR
2/RC5 - UART RX
3/RC4 - UART TX
4/RC3 - UART CTS
5/RC6 - UART RTS
6/RC7 - BLE RESET
7/RB7 - Acc Interrupt 1
8/RB6 - I2C SCL
9/RB5 - Mag Interrupt
10/RB4 - I2C SDA
11/RC2 - BLE SLEEP
12/RC1 - LED
13/RC0 - BLE Mode Toggle
14/RA2 - Gyro Interrupt 2
15/RA1 - ICSPCLK
16/RA0 - ISCLDAT
17/VSS - GND
18/VDD - VDD
19/RA5 - T1 OSO
20/RA4 - T1 OSO
*/
// </editor-fold>
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/Makefile-default.mk
45,11 → 45,11
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
 
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/main.p1.d
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.p1 ${OBJECTDIR}/TIMER.p1 ${OBJECTDIR}/INTERRUPT.p1 ${OBJECTDIR}/UART.p1 ${OBJECTDIR}/I2C.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/main.p1.d ${OBJECTDIR}/TIMER.p1.d ${OBJECTDIR}/INTERRUPT.p1.d ${OBJECTDIR}/UART.p1.d ${OBJECTDIR}/I2C.p1.d
 
# Object Files
OBJECTFILES=${OBJECTDIR}/main.p1
OBJECTFILES=${OBJECTDIR}/main.p1 ${OBJECTDIR}/TIMER.p1 ${OBJECTDIR}/INTERRUPT.p1 ${OBJECTDIR}/UART.p1 ${OBJECTDIR}/I2C.p1
 
 
CFLAGS=
79,6 → 79,34
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/TIMER.p1: TIMER.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/TIMER.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/TIMER.p1 TIMER.c
@-${MV} ${OBJECTDIR}/TIMER.d ${OBJECTDIR}/TIMER.p1.d
@${FIXDEPS} ${OBJECTDIR}/TIMER.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/INTERRUPT.p1: INTERRUPT.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/INTERRUPT.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/INTERRUPT.p1 INTERRUPT.c
@-${MV} ${OBJECTDIR}/INTERRUPT.d ${OBJECTDIR}/INTERRUPT.p1.d
@${FIXDEPS} ${OBJECTDIR}/INTERRUPT.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/UART.p1: UART.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/UART.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/UART.p1 UART.c
@-${MV} ${OBJECTDIR}/UART.d ${OBJECTDIR}/UART.p1.d
@${FIXDEPS} ${OBJECTDIR}/UART.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/I2C.p1: I2C.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/I2C.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/I2C.p1 I2C.c
@-${MV} ${OBJECTDIR}/I2C.d ${OBJECTDIR}/I2C.p1.d
@${FIXDEPS} ${OBJECTDIR}/I2C.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
else
${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
87,6 → 115,34
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/TIMER.p1: TIMER.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/TIMER.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/TIMER.p1 TIMER.c
@-${MV} ${OBJECTDIR}/TIMER.d ${OBJECTDIR}/TIMER.p1.d
@${FIXDEPS} ${OBJECTDIR}/TIMER.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/INTERRUPT.p1: INTERRUPT.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/INTERRUPT.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/INTERRUPT.p1 INTERRUPT.c
@-${MV} ${OBJECTDIR}/INTERRUPT.d ${OBJECTDIR}/INTERRUPT.p1.d
@${FIXDEPS} ${OBJECTDIR}/INTERRUPT.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/UART.p1: UART.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/UART.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/UART.p1 UART.c
@-${MV} ${OBJECTDIR}/UART.d ${OBJECTDIR}/UART.p1.d
@${FIXDEPS} ${OBJECTDIR}/UART.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/I2C.p1: I2C.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/I2C.p1.d
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --asmlist --double=24 --float=24 --opt=default,+asm,-asmfile,+speed,-space,-debug,9 --addrqual=ignore --mode=free -P -N255 --warn=0 --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/I2C.p1 I2C.c
@-${MV} ${OBJECTDIR}/I2C.d ${OBJECTDIR}/I2C.p1.d
@${FIXDEPS} ${OBJECTDIR}/I2C.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
endif
 
# ------------------------------------------------------------------------------------
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/Makefile-genesis.properties
1,6 → 1,6
#
#Mon May 06 15:34:30 EDT 2013
default.languagetoolchain.dir=C\:\\PROGRAM FILES (X86)\\MICROCHIP\\XC8\\V1.12\\BIN
#Fri May 31 18:15:01 EDT 2013
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.12\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=415494acd195d89b2f6d7a36797a5ab4
default.languagetoolchain.version=1.12
host.platform=windows
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/Makefile-local-default.mk
21,7 → 21,7
# Path to java used to run MPLAB X when this makefile was created
MP_JAVA_PATH="C:\Program Files (x86)\Microchip\MPLABX\sys\java\jre1.6.0_32-windows-x64\java-windows/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\PROGRAM FILES (X86)\MICROCHIP\XC8\V1.12\BIN\xc8.exe"
MP_CC="C:\Program Files (x86)\Microchip\xc8\v1.12\bin\xc8.exe"
# MP_CPPC is not defined
# MP_BC is not defined
# MP_AS is not defined
28,7 → 28,7
# MP_LD is not defined
# MP_AR is not defined
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar"
MP_CC_DIR="C:\PROGRAM FILES (X86)\MICROCHIP\XC8\V1.12\BIN"
MP_CC_DIR="C:\Program Files (x86)\Microchip\xc8\v1.12\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
# MP_AS_DIR is not defined
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/configurations.xml
4,6 → 4,10
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>main.h</itemPath>
<itemPath>TIMER.h</itemPath>
<itemPath>INTERRUPT.h</itemPath>
<itemPath>UART.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
13,6 → 17,9
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>TIMER.c</itemPath>
<itemPath>INTERRUPT.c</itemPath>
<itemPath>UART.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
138,7 → 145,7
<property key="programoptions.preserveprogramrange.start" value="0x0"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="true"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</PICkit3PlatformTool>
<XC8-config-global>
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/private/configurations.xml
5,7 → 5,7
<confs>
<conf name="default" type="2">
<platformToolSN>:=MPLABCommUSB:=04D8:=900A:=0002:=Microchip Technology Inc.:=PICkit 3:=BUR114189291:=x:=en</platformToolSN>
<languageToolchainDir>C:\PROGRAM FILES (X86)\MICROCHIP\XC8\V1.12\BIN</languageToolchainDir>
<languageToolchainDir>C:\Program Files (x86)\Microchip\xc8\v1.12\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
/PIC Stuff/PICX_16F1829_BLE_IMU/nbproject/project.xml
8,7 → 8,7
<make-project-type>0</make-project-type>
<c-extensions>c</c-extensions>
<cpp-extensions/>
<header-extensions/>
<header-extensions>h</header-extensions>
<sourceEncoding>ISO-8859-1</sourceEncoding>
<make-dep-projects/>
</data>