Subversion Repositories Code-Repo

Compare Revisions

No changes between revisions

Ignore whitespace Rev 227 → Rev 228

/PIC Stuff/PICX_16F1825_Controller/Makefile
0,0 → 1,113
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
 
 
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
RANLIB=ranlib
 
 
# build
build: .build-post
 
.build-pre:
# Add your pre 'build' code here...
 
.build-post: .build-impl
# Add your post 'build' code here...
 
 
# clean
clean: .clean-post
 
.clean-pre:
# Add your pre 'clean' code here...
# WARNING: the IDE does not call this target since it takes a long time to
# simply run make. Instead, the IDE removes the configuration directories
# under build and dist directly without calling make.
# This target is left here so people can do a clean when running a clean
# outside the IDE.
 
.clean-post: .clean-impl
# Add your post 'clean' code here...
 
 
# clobber
clobber: .clobber-post
 
.clobber-pre:
# Add your pre 'clobber' code here...
 
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
 
 
# all
all: .all-post
 
.all-pre:
# Add your pre 'all' code here...
 
.all-post: .all-impl
# Add your post 'all' code here...
 
 
# help
help: .help-post
 
.help-pre:
# Add your pre 'help' code here...
 
.help-post: .help-impl
# Add your post 'help' code here...
 
 
 
# include project implementation makefile
include nbproject/Makefile-impl.mk
 
# include project make variables
include nbproject/Makefile-variables.mk
/PIC Stuff/PICX_16F1825_Controller/base_I2C.c
0,0 → 1,548
#include <xc.h>
#include "defines.h"
#include "base_I2C.h"
 
static I2C_DATA *i2c_data_p;
 
// 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) {
i2c_data_p = data;
i2c_data_p->buffer_in_len = 0;
i2c_data_p->buffer_in_len_tmp = 0;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
i2c_data_p->buffer_out_ind = 0;
i2c_data_p->buffer_out_len = 0;
i2c_data_p->operating_mode = 0;
i2c_data_p->operating_state = I2C_IDLE;
i2c_data_p->return_status = 0;
 
i2c_data_p->slave_in_last_byte = 0;
i2c_data_p->slave_sending_data = 0;
 
i2c_data_p->master_dest_addr = 0;
i2c_data_p->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) {
i2c_data_p->operating_mode = I2C_MODE_MASTER;
 
I2C_CLK_TRIS = 1;
I2C_DAT_TRIS = 1;
 
SSPSTAT = 0x0;
SSPCON1 = 0x0;
SSPCON2 = 0x0;
SSPCON1bits.SSPM = 0x8; // I2C Master Mode
if (!speed) {
SSPADD = 0x13; // Operate at 400KHz (32MHz)
} else {
SSPADD = 0x4F; // Operate at 100KHz (32MHz)
}
SSPSTATbits.SMP = 1; // Disable Slew Rate Control
SSPCON1bits.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++) {
i2c_data_p->buffer_in[i] = msg[i];
}
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C_SEND_ADDR;
i2c_data_p->master_status = I2C_MASTER_SEND;
// Generate start condition
SSPCON2bits.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
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C_SEND_ADDR;
i2c_data_p->master_status = I2C_MASTER_RECV;
// Generate start condition
SSPCON2bits.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
i2c_data_p->buffer_in[0] = msg;
i2c_data_p->buffer_in_len = length;
i2c_data_p->master_dest_addr = address;
i2c_data_p->buffer_in_read_ind = 0;
i2c_data_p->buffer_in_write_ind = 0;
 
// Change status to 'next' operation
i2c_data_p->operating_state = I2C_SEND_ADDR;
i2c_data_p->master_status = I2C_MASTER_RESTART;
 
// Generate start condition
SSPCON2bits.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) {
i2c_data_p->operating_mode = I2C_MODE_SLAVE;
 
// Ensure the two lines are set for input (we are a slave)
I2C_CLK_TRIS = 1;
I2C_DAT_TRIS = 1;
 
SSPADD = addr << 1; // Set the slave address
 
SSPSTAT = 0x0;
SSPCON1 = 0x0;
SSPCON2 = 0x0;
SSPCON1bits.SSPM = 0xE; // Enable Slave 7-bit w/ start/stop interrupts
SSPSTATbits.SMP = 1; // Slew Off
SSPCON2bits.SEN = 1; // Enable clock-stretching
SSPCON1bits.SSPEN = 1; // Enable MSSP Module
}
 
void I2C_Interrupt_Handler() {
// Call interrupt depending on which mode we are operating in
if (i2c_data_p->operating_mode == I2C_MODE_MASTER) {
I2C_Interrupt_Master();
} else if (i2c_data_p->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 (i2c_data_p->master_status == I2C_MASTER_SEND) {
switch (i2c_data_p->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send the address with read bit set
i2c_data_p->operating_state = I2C_CHECK_ACK_SEND;
SSPBUF = (i2c_data_p->master_dest_addr << 1) | 0x0;
break;
case I2C_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!SSPCON2bits.ACKSTAT) {
// If an ACK is received, send next byte of data
if (i2c_data_p->buffer_in_read_ind < i2c_data_p->buffer_in_len) {
SSPBUF = i2c_data_p->buffer_in[i2c_data_p->buffer_in_read_ind];
i2c_data_p->buffer_in_read_ind++;
} else {
// If no more data is to be sent, send stop bit
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_SEND_OK;
}
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_SEND_FAIL;
}
break;
}
// If we are in the middle of receiving data
} else if (i2c_data_p->master_status == I2C_MASTER_RECV) {
switch (i2c_data_p->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send address with write bit set
i2c_data_p->operating_state = I2C_CHECK_ACK_RECV;
SSPBUF = (i2c_data_p->master_dest_addr << 1) | 0x1;
break;
case I2C_CHECK_ACK_RECV:
// Check if ACK is received
if (!SSPCON2bits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
i2c_data_p->operating_state = I2C_RCV_DATA;
SSPCON2bits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_RECV_FAIL;
}
break;
case I2C_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = SSPBUF;
i2c_data_p->buffer_in_write_ind++;
if (i2c_data_p->buffer_in_write_ind < i2c_data_p->buffer_in_len) {
// If we still need to read, send an ACK to the slave
i2c_data_p->operating_state = I2C_REQ_DATA;
SSPCON2bits.ACKDT = 0; // ACK
SSPCON2bits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
i2c_data_p->operating_state = I2C_SEND_STOP;
SSPCON2bits.ACKDT = 1; // NACK
SSPCON2bits.ACKEN = 1;
}
break;
case I2C_REQ_DATA:
// Set module to receive one byte of data
i2c_data_p->operating_state = I2C_RCV_DATA;
SSPCON2bits.RCEN = 1;
break;
case I2C_SEND_STOP:
// Send the stop bit and copy message to send to Main()
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_RECV_OK;
break;
}
} else if (i2c_data_p->master_status == I2C_MASTER_RESTART) {
switch (i2c_data_p->operating_state) {
case I2C_IDLE:
break;
case I2C_SEND_ADDR:
// Send the address with read bit set
i2c_data_p->operating_state = I2C_CHECK_ACK_SEND;
SSPBUF = (i2c_data_p->master_dest_addr << 1) | 0x0;
break;
case I2C_CHECK_ACK_SEND:
// Check if ACK is received or not
if (!SSPCON2bits.ACKSTAT) {
// If an ACK is received, send first byte of data
SSPBUF = i2c_data_p->buffer_in[0];
i2c_data_p->operating_state = I2C_CHECK_ACK_RESTART;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_SEND_FAIL;
}
break;
case I2C_CHECK_ACK_RESTART:
if (!SSPCON2bits.ACKSTAT) {
SSPCON2bits.RSEN = 1;
i2c_data_p->operating_state = I2C_SEND_ADDR_2;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_SEND_FAIL;
}
break;
case I2C_SEND_ADDR_2:
// Send the address with read bit set
i2c_data_p->operating_state = I2C_CHECK_ACK_RECV;
SSPBUF = (i2c_data_p->master_dest_addr << 1) | 0x1;
break;
case I2C_CHECK_ACK_RECV:
// Check if ACK is received
if (!SSPCON2bits.ACKSTAT) {
// If an ACK is received, set module to receive 1 byte of data
i2c_data_p->operating_state = I2C_RCV_DATA;
SSPCON2bits.RCEN = 1;
} else {
// If a NACK is received, stop transmission and send error
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->return_status = I2C_RECV_FAIL;
}
break;
case I2C_RCV_DATA:
// On receive, save byte into buffer
// TODO: Handle I2C buffer overflow
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = SSPBUF;
i2c_data_p->buffer_in_write_ind++;
if (i2c_data_p->buffer_in_write_ind < i2c_data_p->buffer_in_len) {
// If we still need to read, send an ACK to the slave
i2c_data_p->operating_state = I2C_REQ_DATA;
SSPCON2bits.ACKDT = 0; // ACK
SSPCON2bits.ACKEN = 1;
} else {
// If we are done reading, send an NACK to the slave
i2c_data_p->operating_state = I2C_SEND_STOP;
SSPCON2bits.ACKDT = 1; // NACK
SSPCON2bits.ACKEN = 1;
}
break;
case I2C_REQ_DATA:
// Set module to receive one byte of data
i2c_data_p->operating_state = I2C_RCV_DATA;
SSPCON2bits.RCEN = 1;
break;
case I2C_SEND_STOP:
// Send the stop bit and copy message to send to Main()
i2c_data_p->operating_state = I2C_IDLE;
SSPCON2bits.PEN = 1;
i2c_data_p->master_status = I2C_MASTER_IDLE;
i2c_data_p->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 (SSPCON1bits.SSPOV == 1) {
SSPCON1bits.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
i2c_data_p->operating_state = I2C_IDLE;
overrun_error = 1;
i2c_data_p->return_status = I2C_ERR_OVERRUN;
}
 
// Read SPPxBUF if it is full
if (SSPSTATbits.BF == 1) {
received_data = SSPBUF;
// DBG_PRINT_I2C("I2C: data read from buffer: %x\r\n", SSPBUF);
data_read_from_buffer = 1;
}
 
if (!overrun_error) {
switch (i2c_data_p->operating_state) {
case I2C_IDLE:
{
// Ignore anything except a start
if (SSPSTATbits.S == 1) {
i2c_data_p->buffer_in_len_tmp = 0;
i2c_data_p->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
// i2c_data_p->operating_state = I2C_IDLE;
// i2c_data_p->return_status = I2C_ERR_NOADDR;
// } else {
// // Determine if we are sending or receiving data
// if (SSPSTATbits.R_W == 1) {
// i2c_data_p->operating_state = I2C_SEND_DATA;
// } else {
// i2c_data_p->operating_state = I2C_RCV_DATA;
// }
// }
// } else {
// i2c_data_p->operating_state = I2C_STARTED;
// }
}
break;
}
case I2C_STARTED:
{
// In this case, we expect either an address or a stop bit
if (SSPSTATbits.P == 1) {
// Return to idle mode
i2c_data_p->operating_state = I2C_IDLE;
} else if (data_read_from_buffer) {
if (SSPSTATbits.D_nA == 0) {
// Address received
if (SSPSTATbits.R_nW == 0) {
// Slave write mode
i2c_data_p->operating_state = I2C_RCV_DATA;
} else {
// Slave read mode
i2c_data_p->operating_state = I2C_SEND_DATA;
// Process the first byte immediatly if sending data
goto send;
}
} else {
i2c_data_p->operating_state = I2C_IDLE;
i2c_data_p->return_status = I2C_ERR_NODATA;
}
}
break;
}
send:
case I2C_SEND_DATA:
{
if (!i2c_data_p->slave_sending_data) {
// If we are not currently sending data, figure out what to reply with
if (I2C_Process_Send(i2c_data_p->slave_in_last_byte)) {
// Data exists to be returned, send first byte
SSPBUF = i2c_data_p->buffer_out[0];
i2c_data_p->buffer_out_ind = 1;
i2c_data_p->slave_sending_data = 1;
data_written_to_buffer = 1;
} else {
// Unknown request
i2c_data_p->slave_sending_data = 0;
i2c_data_p->operating_state = I2C_IDLE;
}
} else {
// Sending remaining data back to master
if (i2c_data_p->buffer_out_ind < i2c_data_p->buffer_out_len) {
SSPBUF = i2c_data_p->buffer_out[i2c_data_p->buffer_out_ind];
i2c_data_p->buffer_out_ind++;
data_written_to_buffer = 1;
} else {
// Nothing left to send
i2c_data_p->slave_sending_data = 0;
i2c_data_p->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 (SSPSTATbits.P == 1) {
// Stop bit detected, we need to check to see if we also read data
if (data_read_from_buffer) {
if (SSPSTATbits.D_nA == 1) {
// Data received with stop bit
// TODO: Handle I2C buffer overflow
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = received_data;
if (i2c_data_p->buffer_in_write_ind == MAXI2CBUF-1) {
i2c_data_p->buffer_in_write_ind = 0;
} else {
i2c_data_p->buffer_in_write_ind++;
}
i2c_data_p->buffer_in_len_tmp++;
// Save the last byte received
i2c_data_p->slave_in_last_byte = received_data;
i2c_data_p->return_status = I2C_DATA_AVAL;
} else {
i2c_data_p->operating_state = I2C_IDLE;
i2c_data_p->return_status = I2C_ERR_NODATA;
}
}
i2c_data_p->buffer_in_len += i2c_data_p->buffer_in_len_tmp;
i2c_data_p->operating_state = I2C_IDLE;
} else if (data_read_from_buffer) {
if (SSPSTATbits.D_nA == 1) {
// Data received
i2c_data_p->buffer_in[i2c_data_p->buffer_in_write_ind] = received_data;
if (i2c_data_p->buffer_in_write_ind == MAXI2CBUF-1) {
i2c_data_p->buffer_in_write_ind = 0;
} else {
i2c_data_p->buffer_in_write_ind++;
}
i2c_data_p->buffer_in_len_tmp++;
// Save the last byte received
i2c_data_p->slave_in_last_byte = received_data;
i2c_data_p->return_status = I2C_DATA_AVAL;
} else {
// Restart bit detected
if (SSPSTATbits.R_nW == 1) {
i2c_data_p->buffer_in_len += i2c_data_p->buffer_in_len_tmp;
i2c_data_p->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
i2c_data_p->operating_state = I2C_IDLE;
i2c_data_p->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 (SSPCON1bits.CKP == 0) {
SSPCON1bits.CKP = 1;
}
}
}
 
/* Returns 0 if I2C module is currently busy, otherwise returns status code */
char I2C_Get_Status() {
if (i2c_data_p->operating_mode == I2C_MODE_MASTER) {
if (i2c_data_p->master_status != I2C_MASTER_IDLE || i2c_data_p->buffer_in_len == 0) {
return 0;
} else {
return i2c_data_p->return_status;
}
} else {
if (i2c_data_p->operating_state != I2C_IDLE || i2c_data_p->buffer_in_len == 0) {
return 0;
} else {
return i2c_data_p->return_status;
}
}
}
 
char I2C_Buffer_Len() {
return i2c_data_p->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 (i2c_data_p->buffer_in_len != 0) {
buffer[i] = i2c_data_p->buffer_in[i2c_data_p->buffer_in_read_ind];
i++;
if (i2c_data_p->buffer_in_read_ind == MAXI2CBUF-1) {
i2c_data_p->buffer_in_read_ind = 0;
} else {
i2c_data_p->buffer_in_read_ind++;
}
i2c_data_p->buffer_in_len--;
}
return i;
}
 
/* Put data to be returned here */
char I2C_Process_Send(char c) {
char ret = 0;
BTN_STATUS btns;
switch (c) {
case CMD_QUERY_BTN:
Pins_Read(&btns);
i2c_data_p->buffer_out[0] = btns.value;
i2c_data_p->buffer_out_len = 1;
ret = 1;
break;
}
return ret;
}
/PIC Stuff/PICX_16F1825_Controller/base_I2C.h
0,0 → 1,81
#ifndef I2C_H
#define I2C_H
 
#define MAXI2CBUF 32
 
// 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
#define I2C_SEND_OK 0x30
#define I2C_SEND_FAIL 0x31
#define I2C_RECV_OK 0x32
#define I2C_RECV_FAIL 0x33
#define I2C_DATA_AVAL 0x34
#define I2C_ERR_NOADDR 0x35
#define I2C_ERR_OVERRUN 0x36
#define I2C_ERR_NODATA 0x37
#define I2C_ERR_BUFFER_OVERRUN 0x38
 
typedef struct {
char buffer_in[MAXI2CBUF];
char buffer_in_len;
char buffer_in_len_tmp;
char buffer_in_read_ind;
char buffer_in_write_ind;
char buffer_out[MAXI2CBUF];
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
/PIC Stuff/PICX_16F1825_Controller/base_INTERRUPTS.c
0,0 → 1,80
#include <xc.h>
#include "defines.h"
#include "base_INTERRUPTS.h"
#include "base_I2C.h"
 
void Interrupt_Init() {
// Enable MSSP1 interrupt
PIE1bits.SSP1IE = 1;
}
 
void Interrupt_Enable() {
// Enable global and peripheral interrupts
INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;
}
 
void Interrupt_Disable() {
INTCONbits.PEIE = 0;
INTCONbits.GIE = 0;
}
 
void interrupt InterruptHandler(void) {
// We need to check the interrupt flag of each enabled high-priority interrupt to
// see which device generated this interrupt. Then we can call the correct handler.
 
// // Check to see if we have an SPI2 interrupt
// if (PIR3bits.SSP2IF) {
// // Call the handler
// SPI2_Recv_Interrupt_Handler();
//
// // Clear the interrupt flag
// PIR3bits.SSP2IF = 0;
//
// return;
// }
 
// Check to see if we have an I2C interrupt
if (PIR1bits.SSP1IF) {
 
// Call the handler
I2C_Interrupt_Handler();
 
// Clear the interrupt flag
PIR1bits.SSP1IF = 0;
 
return;
}
 
// // Check to see if we have an interrupt on USART1 RX
// if (PIR1bits.RC1IF) {
// // Call the interrupt handler
// UART1_Recv_Interrupt_Handler();
//
// // Clear the interrupt flag
// PIR1bits.RC1IF = 0;
//
// return;
// }
 
// // Check to see if we have an interrupt on USART1 TX
// if (PIR1bits.TX1IF) {
// // Call the interrupt handler
// UART1_Send_Interrupt_Handler();
//
// // Clear the interrupt flag
// PIR1bits.TX1IF = 0;
//
// return;
// }
 
// // Check to see if we have an interrupt on USART2 RX
// if (PIR3bits.RC2IF) {
// DBG_PRINT_INT("INT: UART2 RX\r\n");
// // Call the interrupt handler
// uart_2_recv_interrupt_handler();
//
// // Clear the interrupt flag
// PIR3bits.RC2IF = 0;
// }
}
/PIC Stuff/PICX_16F1825_Controller/base_INTERRUPTS.h
0,0 → 1,15
#ifndef INTERRUPTS_H
#define INTERRUPTS_H
 
// Initialize the interrupts
void Interrupt_Init(void);
 
// Enable all interrupts (high and low priority)
void Interrupt_Enable(void);
 
// Disable all interrupts (high and low priority)
void Interrupt_Disable(void);
 
void interrupt InterruptHandler(void);
 
#endif
/PIC Stuff/PICX_16F1825_Controller/defines.h
0,0 → 1,77
#ifndef DEFINES_H
#define DEFINES_H
 
// <editor-fold defaultstate="collapsed" desc="I/O Pins">
#define BTN_L_N_TRIS TRISAbits.TRISA1
#define BTN_L_N_PORT PORTAbits.RA1
#define BTN_L_N_WPU WPUAbits.WPUA1
 
#define BTN_L_S_TRIS TRISAbits.TRISA0
#define BTN_L_S_PORT PORTAbits.RA0
#define BTN_L_S_WPU WPUAbits.WPUA0
 
#define BTN_R_N_TRIS TRISCbits.TRISC2
#define BTN_R_N_PORT PORTCbits.RC2
#define BTN_R_N_WPU WPUCbits.WPUC2
 
#define BTN_R_E_TRIS TRISAbits.TRISA3
#define BTN_R_E_PORT PORTAbits.RA3
#define BTN_R_E_WPU WPUAbits.WPUA3
 
#define BTN_R_S_TRIS TRISAbits.TRISA5
#define BTN_R_S_PORT PORTAbits.RA5
#define BTN_R_S_WPU WPUAbits.WPUA5
 
#define BTN_R_W_TRIS TRISAbits.TRISA2
#define BTN_R_W_PORT PORTAbits.RA2
#define BTN_R_W_WPU WPUAbits.WPUA2
 
#define LED_1_TRIS TRISCbits.TRISC3
#define LED_1_LAT LATCbits.LATC3
 
#define LED_2_TRIS TRISCbits.TRISC4
#define LED_2_LAT LATCbits.LATC4
 
#define LED_3_TRIS TRISCbits.TRISC5
#define LED_3_LAT LATCbits.LATC5
 
#define LED_4_TRIS TRISAbits.TRISA4
#define LED_4_LAT LATAbits.LATA4
 
#define I2C_CLK_TRIS TRISCbits.TRISC0
#define I2C_DAT_TRIS TRISCbits.TRISC1
// </editor-fold>
 
#define _XTAL_FREQ 32000000
 
#define CMD_QUERY_BTN 0x10
#define CMD_SET_LEDS 0x11
 
typedef union {
struct {
unsigned BTN_L_N :1;
unsigned BTN_L_S :1;
unsigned BTN_R_N :1;
unsigned BTN_R_E :1;
unsigned BTN_R_S :1;
unsigned BTN_R_W :1;
unsigned :2;
};
char value;
} BTN_STATUS;
 
typedef union {
struct {
unsigned LED_1 :1;
unsigned LED_2 :1;
unsigned LED_3 :1;
unsigned LED_4 :1;
};
char value;
} LED_STATUS;
 
void Pins_Read(BTN_STATUS *btns);
void Leds_Write(LED_STATUS *leds);
 
#endif /* DEFINES_H */
 
/PIC Stuff/PICX_16F1825_Controller/funclist
0,0 → 1,17
_I2C_Get_Status: CODE, 1171 0 54
_I2C_Interrupt_Master: CODE, 19 0 591
_I2C_Read_Buffer: CODE, 1046 0 65
_I2C_Interrupt_Slave: CODE, 610 0 358
_main: CODE, 1111 0 60
_Interrupt_Enable: CODE, 1444 0 3
_I2C_Configure_Slave: CODE, 1391 0 28
_InterruptHandler: CODE, 4 0 13
_I2C_Process_Send: CODE, 1360 0 31
_I2C_Interrupt_Handler: CODE, 1419 0 22
_Interrupt_Init: CODE, 1447 0 3
__initialization: CODE, 1441 0 0
_I2C_Init: CODE, 968 0 78
_Pins_Read: CODE, 1316 0 44
_Pins_Init: CODE, 1271 0 45
_Leds_Write: CODE, 1225 0 46
Total: 1441
/PIC Stuff/PICX_16F1825_Controller/main.c
0,0 → 1,117
// <editor-fold defaultstate="collapsed" desc="Configuration Bits">
// PIC16F1825 Configuration Bit Settings
 
// CONFIG1
#pragma config FOSC = INTOSC // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
#pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)
 
// CONFIG2
#pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = ON // PLL Enable (4x PLL enabled)
#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 = OFF // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
// </editor-fold>
 
#include <xc.h>
#include "defines.h"
#include "base_INTERRUPTS.h"
#include "base_I2C.h"
 
__persistent int temp;
 
void Pins_Init(void) {
// Set all pins to digital I/O
ANSELA = 0x0;
ANSELC = 0x0;
 
// Enable weak pull-up if WPU bit is set
OPTION_REGbits.nWPUEN = 0;
 
// Set buttons as inputs and enable weak pull-ups
BTN_L_N_TRIS = 1;
BTN_L_N_WPU = 1;
BTN_L_S_TRIS = 1;
BTN_L_S_WPU = 1;
 
BTN_R_N_TRIS = 1;
BTN_R_N_WPU = 1;
BTN_R_E_TRIS = 1;
BTN_R_E_WPU = 1;
BTN_R_S_TRIS = 1;
BTN_R_S_WPU = 1;
BTN_R_W_TRIS = 1;
BTN_R_W_WPU = 1;
 
// Set leds as outputs and initialize to off
LED_1_TRIS = 0;
LED_1_LAT = 0;
LED_2_TRIS = 0;
LED_2_LAT = 0;
LED_3_TRIS = 0;
LED_3_LAT = 0;
LED_4_TRIS = 0;
LED_4_LAT = 0;
}
 
// Function to read button status into a data structure
void Pins_Read(BTN_STATUS *btns) {
btns->BTN_L_N = BTN_L_N_PORT;
btns->BTN_L_S = BTN_L_S_PORT;
 
btns->BTN_R_N = BTN_R_N_PORT;
btns->BTN_R_E = BTN_R_E_PORT;
btns->BTN_R_S = BTN_R_S_PORT;
btns->BTN_R_W = BTN_R_W_PORT;
}
 
// Function to write led values from the data structure
void Leds_Write(LED_STATUS *leds) {
LED_1_LAT = leds->LED_1;
LED_2_LAT = leds->LED_2;
LED_3_LAT = leds->LED_3;
LED_4_LAT = leds->LED_4;
}
 
int main(void) {
char buffer[32];
char result, length;
 
// Set internal oscillator speed to 32MHz
OSCCONbits.SPLLEN = 1; // 4x PLL enable (overwritten by config bits)
OSCCONbits.IRCF = 0xE; // Base frequency @ 8MHz
OSCCONbits.SCS = 0b00; // System clock determined by config bits
 
// Initialize I/O
Pins_Init();
 
// Initialize I2C in slave mode
I2C_DATA i2c_data;
I2C_Init(&i2c_data);
I2C_Configure_Slave(0x24);
 
// Initialize interrupts
Interrupt_Init();
Interrupt_Enable();
 
while (1) {
do {
result = I2C_Get_Status();
} while (!result);
length = I2C_Read_Buffer(buffer);
if (length == 2 && buffer[0] == CMD_SET_LEDS) {
LED_STATUS leds;
leds.value = buffer[1];
Leds_Write(&leds);
}
}
}
 
/PIC Stuff/PICX_16F1825_Controller/nbproject/Makefile-default.mk
0,0 → 1,188
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
 
 
# Include project Makefile
ifeq "${IGNORE_LOCAL}" "TRUE"
# do not include local makefile. User is passing all local related variables already
else
include Makefile
# Include makefile containing local settings
ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk"
include nbproject/Makefile-local-default.mk
endif
endif
 
# Environment
MKDIR=gnumkdir -p
RM=rm -f
MV=mv
CP=cp
 
# Macros
CND_CONF=default
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
IMAGE_TYPE=debug
OUTPUT_SUFFIX=elf
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
else
IMAGE_TYPE=production
OUTPUT_SUFFIX=hex
DEBUGGABLE_SUFFIX=elf
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
endif
 
# Object Directory
OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
 
# Distribution Directory
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
 
# Source Files Quoted if spaced
SOURCEFILES_QUOTED_IF_SPACED=main.c base_I2C.c base_INTERRUPTS.c base_MAIN_PWM.c
 
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.p1 ${OBJECTDIR}/base_I2C.p1 ${OBJECTDIR}/base_INTERRUPTS.p1 ${OBJECTDIR}/base_MAIN_PWM.p1
POSSIBLE_DEPFILES=${OBJECTDIR}/main.p1.d ${OBJECTDIR}/base_I2C.p1.d ${OBJECTDIR}/base_INTERRUPTS.p1.d ${OBJECTDIR}/base_MAIN_PWM.p1.d
 
# Object Files
OBJECTFILES=${OBJECTDIR}/main.p1 ${OBJECTDIR}/base_I2C.p1 ${OBJECTDIR}/base_INTERRUPTS.p1 ${OBJECTDIR}/base_MAIN_PWM.p1
 
# Source Files
SOURCEFILES=main.c base_I2C.c base_INTERRUPTS.c base_MAIN_PWM.c
 
 
CFLAGS=
ASFLAGS=
LDLIBSOPTIONS=
 
############# Tool locations ##########################################
# If you copy a project from one host to another, the path where the #
# compiler is installed may be different. #
# If you open this project with MPLAB X in the new host, this #
# makefile will be regenerated and the paths will be corrected. #
#######################################################################
# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build
FIXDEPS=fixDeps
 
.build-conf: ${BUILD_SUBPROJECTS}
${MAKE} ${MAKE_OPTIONS} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
 
MP_PROCESSOR_OPTION=16F1825
# ------------------------------------------------------------------------------------
# Rules for buildStep: compile
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/main.p1.d
@${RM} ${OBJECTDIR}/main.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/main.p1 main.c
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_I2C.p1: base_I2C.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_I2C.p1.d
@${RM} ${OBJECTDIR}/base_I2C.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_I2C.p1 base_I2C.c
@-${MV} ${OBJECTDIR}/base_I2C.d ${OBJECTDIR}/base_I2C.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_I2C.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_INTERRUPTS.p1: base_INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_INTERRUPTS.p1 base_INTERRUPTS.c
@-${MV} ${OBJECTDIR}/base_INTERRUPTS.d ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_MAIN_PWM.p1: base_MAIN_PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_MAIN_PWM.p1.d
@${RM} ${OBJECTDIR}/base_MAIN_PWM.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_MAIN_PWM.p1 base_MAIN_PWM.c
@-${MV} ${OBJECTDIR}/base_MAIN_PWM.d ${OBJECTDIR}/base_MAIN_PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_MAIN_PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
else
${OBJECTDIR}/main.p1: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/main.p1.d
@${RM} ${OBJECTDIR}/main.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/main.p1 main.c
@-${MV} ${OBJECTDIR}/main.d ${OBJECTDIR}/main.p1.d
@${FIXDEPS} ${OBJECTDIR}/main.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_I2C.p1: base_I2C.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_I2C.p1.d
@${RM} ${OBJECTDIR}/base_I2C.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_I2C.p1 base_I2C.c
@-${MV} ${OBJECTDIR}/base_I2C.d ${OBJECTDIR}/base_I2C.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_I2C.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_INTERRUPTS.p1: base_INTERRUPTS.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${RM} ${OBJECTDIR}/base_INTERRUPTS.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_INTERRUPTS.p1 base_INTERRUPTS.c
@-${MV} ${OBJECTDIR}/base_INTERRUPTS.d ${OBJECTDIR}/base_INTERRUPTS.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_INTERRUPTS.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
${OBJECTDIR}/base_MAIN_PWM.p1: base_MAIN_PWM.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/base_MAIN_PWM.p1.d
@${RM} ${OBJECTDIR}/base_MAIN_PWM.p1
${MP_CC} --pass1 $(MP_EXTRA_CC_PRE) --chip=$(MP_PROCESSOR_OPTION) -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -o${OBJECTDIR}/base_MAIN_PWM.p1 base_MAIN_PWM.c
@-${MV} ${OBJECTDIR}/base_MAIN_PWM.d ${OBJECTDIR}/base_MAIN_PWM.p1.d
@${FIXDEPS} ${OBJECTDIR}/base_MAIN_PWM.p1.d $(SILENT) -rsi ${MP_CC_DIR}../
endif
 
# ------------------------------------------------------------------------------------
# Rules for buildStep: assemble
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
else
endif
 
# ------------------------------------------------------------------------------------
# Rules for buildStep: link
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) --chip=$(MP_PROCESSOR_OPTION) -G -mdist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.map -D__DEBUG=1 --debugger=pickit3 --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
@${RM} dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.hex
else
dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CC} $(MP_EXTRA_LD_PRE) --chip=$(MP_PROCESSOR_OPTION) -G -mdist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.map --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf "--errformat=%%f:%%l: error: %%s" "--warnformat=%%f:%%l: warning: %%s" "--msgformat=%%f:%%l: advisory: %%s" -odist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
endif
 
 
# Subprojects
.build-subprojects:
 
 
# Subprojects
.clean-subprojects:
 
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r build/default
${RM} -r dist/default
 
# Enable dependency checking
.dep.inc: .depcheck-impl
 
DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES})
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
/PIC Stuff/PICX_16F1825_Controller/nbproject/Makefile-genesis.properties
0,0 → 1,8
#
#Sun Dec 08 16:38:39 EST 2013
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\xc8\\v1.20\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=0d2b1469ad71adb787c711a416386331
default.languagetoolchain.version=1.20
host.platform=windows
conf.ids=default
default.com-microchip-mplab-nbide-toolchainXC8-XC8LanguageToolchain.md5=1b3e17eea10b9e6765d1132465030f97
/PIC Stuff/PICX_16F1825_Controller/nbproject/Makefile-impl.mk
0,0 → 1,69
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
 
 
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
 
 
# Project Name
PROJECTNAME=PICX_16F1825_Controller
 
# Active Configuration
DEFAULTCONF=default
CONF=${DEFAULTCONF}
 
# All Configurations
ALLCONFS=default
 
 
# build
.build-impl: .build-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
 
 
# clean
.clean-impl: .clean-pre
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
 
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean
 
 
 
# all
.all-impl: .all-pre .depcheck-impl
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build
 
 
 
# dependency checking support
.depcheck-impl:
# @echo "# This code depends on make tool being used" >.dep.inc
# @if [ -n "${MAKE_VERSION}" ]; then \
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
# echo "include \$${DEPFILES}" >>.dep.inc; \
# echo "endif" >>.dep.inc; \
# else \
# echo ".KEEP_STATE:" >>.dep.inc; \
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
# fi
/PIC Stuff/PICX_16F1825_Controller/nbproject/Makefile-local-default.mk
0,0 → 1,37
#
# Generated Makefile - do not edit!
#
#
# This file contains information about the location of compilers and other tools.
# If you commmit this file into your revision control server, you will be able to
# to checkout the project and build it from the command line with make. However,
# if more than one person works on the same project, then this file might show
# conflicts since different users are bound to have compilers in different places.
# In that case you might choose to not commit this file and let MPLAB X recreate this file
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
# least once so the file gets created and the project can be built. Finally, you can also
# avoid using this file at all if you are only building from the command line with make.
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
SHELL=cmd.exe
PATH_TO_IDE_BIN=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
PATH:=C:/Program Files (x86)/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH)
# 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.7.0_17/bin/"
OS_CURRENT="$(shell uname -s)"
MP_CC="C:\Program Files (x86)\Microchip\xc8\v1.20\bin\xc8.exe"
# MP_CPPC is not defined
# MP_BC is not defined
# MP_AS is not defined
# 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.20\bin"
# MP_CPPC_DIR is not defined
# MP_BC_DIR is not defined
# MP_AS_DIR is not defined
# MP_LD_DIR is not defined
# MP_AR_DIR is not defined
# MP_BC_DIR is not defined
/PIC Stuff/PICX_16F1825_Controller/nbproject/Makefile-variables.mk
0,0 → 1,13
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
# default configuration
CND_ARTIFACT_DIR_default=dist/default/production
CND_ARTIFACT_NAME_default=PICX_16F1825_Controller.production.hex
CND_ARTIFACT_PATH_default=dist/default/production/PICX_16F1825_Controller.production.hex
CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
CND_PACKAGE_NAME_default=picx16f1825controller.tar
CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/picx16f1825controller.tar
/PIC Stuff/PICX_16F1825_Controller/nbproject/Package-default.bash
0,0 → 1,73
#!/bin/bash -x
 
#
# Generated - do not edit!
#
 
# Macros
TOP=`pwd`
CND_CONF=default
CND_DISTDIR=dist
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
OUTPUT_BASENAME=PICX_16F1825_Controller.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
PACKAGE_TOP_DIR=picx16f1825controller/
 
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
 
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
 
# Copy files and create directories and links
cd "${TOP}"
makeDirectory ${TMPDIR}/picx16f1825controller/bin
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
 
 
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/package/picx16f1825controller.tar
cd ${TMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/picx16f1825controller.tar *
checkReturnCode
 
# Cleanup
cd "${TOP}"
rm -rf ${TMPDIR}
/PIC Stuff/PICX_16F1825_Controller/nbproject/configurations.xml
0,0 → 1,161
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<logicalFolder name="root" displayName="root" projectFiles="true">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true">
<itemPath>defines.h</itemPath>
<itemPath>base_I2C.h</itemPath>
<itemPath>base_INTERRUPTS.h</itemPath>
<itemPath>base_MANUAL_PWM.h</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
projectFiles="true">
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true">
<itemPath>main.c</itemPath>
<itemPath>base_I2C.c</itemPath>
<itemPath>base_INTERRUPTS.c</itemPath>
<itemPath>base_MAIN_PWM.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false">
<itemPath>Makefile</itemPath>
</logicalFolder>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="default" type="2">
<toolsSet>
<developmentServer>localhost</developmentServer>
<targetDevice>PIC16F1825</targetDevice>
<targetHeader></targetHeader>
<targetPluginBoard></targetPluginBoard>
<platformTool>PICkit3PlatformTool</platformTool>
<languageToolchain>XC8</languageToolchain>
<languageToolchainVersion>1.20</languageToolchainVersion>
<platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
<linkerLibItems>
</linkerLibItems>
</linkerTool>
<loading>
<useAlternateLoadableFile>false</useAlternateLoadableFile>
<alternateLoadableFile></alternateLoadableFile>
</loading>
</compileType>
<makeCustomizationType>
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
<makeCustomizationPreStep></makeCustomizationPreStep>
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
<makeCustomizationPostStep></makeCustomizationPostStep>
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
</makeCustomizationType>
<HI-TECH-COMP>
<property key="asmlist" value="true"/>
<property key="define-macros" value=""/>
<property key="extra-include-directories" value=""/>
<property key="identifier-length" value="255"/>
<property key="operation-mode" value="free"/>
<property key="opt-xc8-compiler-strict_ansi" value="false"/>
<property key="optimization-assembler" value="true"/>
<property key="optimization-assembler-files" value="true"/>
<property key="optimization-debug" value="false"/>
<property key="optimization-global" value="true"/>
<property key="optimization-level" value="9"/>
<property key="optimization-set" value="default"/>
<property key="optimization-speed" value="false"/>
<property key="preprocess-assembler" value="true"/>
<property key="undefine-macros" value=""/>
<property key="use-cci" value="false"/>
<property key="use-iar" value="false"/>
<property key="verbose" value="false"/>
<property key="warning-level" value="0"/>
<property key="what-to-do" value="ignore"/>
</HI-TECH-COMP>
<HI-TECH-LINK>
<property key="additional-options-checksum" value=""/>
<property key="additional-options-code-offset" value=""/>
<property key="additional-options-command-line" value=""/>
<property key="additional-options-errata" value=""/>
<property key="additional-options-extend-address" value="false"/>
<property key="additional-options-trace-type" value=""/>
<property key="additional-options-use-response-files" value="false"/>
<property key="backup-reset-condition-flags" value="false"/>
<property key="calibrate-oscillator" value="true"/>
<property key="calibrate-oscillator-value" value=""/>
<property key="clear-bss" value="true"/>
<property key="code-model-external" value="wordwrite"/>
<property key="code-model-rom" value=""/>
<property key="create-html-files" value="false"/>
<property key="data-model-ram" value=""/>
<property key="data-model-size-of-double" value="24"/>
<property key="data-model-size-of-float" value="24"/>
<property key="display-class-usage" value="false"/>
<property key="display-hex-usage" value="false"/>
<property key="display-overall-usage" value="true"/>
<property key="display-psect-usage" value="false"/>
<property key="fill-flash-options-addr" value=""/>
<property key="fill-flash-options-const" value=""/>
<property key="fill-flash-options-how" value="0"/>
<property key="fill-flash-options-inc-const" value="1"/>
<property key="fill-flash-options-increment" value=""/>
<property key="fill-flash-options-seq" value=""/>
<property key="fill-flash-options-what" value="0"/>
<property key="format-hex-file-for-download" value="false"/>
<property key="initialize-data" value="true"/>
<property key="keep-generated-startup.as" value="false"/>
<property key="link-in-c-library" value="true"/>
<property key="link-in-peripheral-library" value="true"/>
<property key="managed-stack" value="false"/>
<property key="opt-xc8-linker-file" value="false"/>
<property key="opt-xc8-linker-link_startup" value="false"/>
<property key="opt-xc8-linker-serial" value=""/>
<property key="program-the-device-with-default-config-words" value="true"/>
</HI-TECH-LINK>
<PICkit3PlatformTool>
<property key="AutoSelectMemRanges" value="auto"/>
<property key="Freeze Peripherals" value="true"/>
<property key="SecureSegment.SegmentProgramming" value="FullChipProgramming"/>
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
<property key="firmware.download.all" value="false"/>
<property key="hwtoolclock.frcindebug" value="false"/>
<property key="memories.aux" value="false"/>
<property key="memories.bootflash" value="false"/>
<property key="memories.configurationmemory" value="false"/>
<property key="memories.eeprom" value="false"/>
<property key="memories.flashdata" value="true"/>
<property key="memories.id" value="false"/>
<property key="memories.programmemory" value="true"/>
<property key="memories.programmemory.end" value="0x1fff"/>
<property key="memories.programmemory.start" value="0x0"/>
<property key="poweroptions.powerenable" value="true"/>
<property key="programmertogo.imagename" value=""/>
<property key="programoptions.eraseb4program" value="true"/>
<property key="programoptions.pgmspeed" value="2"/>
<property key="programoptions.preserveeeprom" value="false"/>
<property key="programoptions.preserveprogramrange" value="false"/>
<property key="programoptions.preserveprogramrange.end" value="0x1fff"/>
<property key="programoptions.preserveprogramrange.start" value="0x0"/>
<property key="programoptions.preserveuserid" value="false"/>
<property key="programoptions.testmodeentrymethod" value="VPPFirst"/>
<property key="programoptions.usehighvoltageonmclr" value="false"/>
<property key="programoptions.uselvpprogramming" value="false"/>
<property key="voltagevalue" value="3.25"/>
</PICkit3PlatformTool>
<XC8-config-global>
<property key="output-file-format" value="-mcof,+elf"/>
</XC8-config-global>
</conf>
</confs>
</configurationDescriptor>
/PIC Stuff/PICX_16F1825_Controller/nbproject/private/SuppressibleMessageMemo.properties
0,0 → 1,3
#
#Sat Dec 07 16:54:55 EST 2013
pk3/CHECK_4_HIGH_VOLTAGE_VPP=true
/PIC Stuff/PICX_16F1825_Controller/nbproject/private/configurations.xml
0,0 → 1,25
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="62">
<projectmakefile>Makefile</projectmakefile>
<defaultConf>0</defaultConf>
<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.20\bin</languageToolchainDir>
<mdbdebugger version="1">
<placeholder1>place holder 1</placeholder1>
<placeholder2>place holder 2</placeholder2>
</mdbdebugger>
<runprofile version="6">
<args></args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>
/PIC Stuff/PICX_16F1825_Controller/nbproject/private/private.properties
--- nbproject/private/private.xml (nonexistent)
+++ nbproject/private/private.xml (revision 228)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?><project-private xmlns="http://www.netbeans.org/ns/project-private/1">
+ <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
+</project-private>
/PIC Stuff/PICX_16F1825_Controller/nbproject/project.properties
--- nbproject/project.xml (nonexistent)
+++ nbproject/project.xml (revision 228)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>com.microchip.mplab.nbide.embedded.makeproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/make-project/1">
+ <name>PICX_16F1825_Controller</name>
+ <creation-uuid>a37f9b7c-e474-41b7-9a5b-bc6808e97a44</creation-uuid>
+ <make-project-type>0</make-project-type>
+ <c-extensions>c</c-extensions>
+ <cpp-extensions/>
+ <header-extensions>h</header-extensions>
+ <sourceEncoding>ISO-8859-1</sourceEncoding>
+ <make-dep-projects/>
+ </data>
+ </configuration>
+</project>