Skip to content

Commit

Permalink
Major copy of changes to chipKIT-core into MPIDE. Lots of various com…
Browse files Browse the repository at this point in the history
…mits in one big merge, unfortunately. Primarily straightening out DTWI as a separate library.

* NOTE: There are significant differences from chipKIT-core boards.txt, platform.txt, and platforms.txt that I did NOT know how to merge, so I left those changes out. Somebody needs to go through all of those changes and merge appropriate ones before MPIDE gets released.
  • Loading branch information
EmbeddedMan committed Oct 10, 2015
1 parent 81d7d27 commit 8468e59
Show file tree
Hide file tree
Showing 21 changed files with 247 additions and 3,404 deletions.
4 changes: 2 additions & 2 deletions build/upload.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Thu, 20 Aug 2015 17:37:53 -0700
#Fri, 09 Oct 2015 18:56:05 -0500
aws.access_key=
aws.secret_key=

extension=dmg

uploadversion=0150-macosx-20150820
uploadversion=0150-windows-20151009-test

2 changes: 1 addition & 1 deletion hardware/pic32/cores/pic32/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ void USBresetRoutine(void)
// Need to return FALSE if we need USB to hold off for awhile
boolean USBstoreDataRoutine(const byte *buffer, int length)
{
unsigned int i;
int i;

// If we have a receive callback defined then repeatedly
// call it with each character.
Expand Down
4 changes: 2 additions & 2 deletions hardware/pic32/cores/pic32/HardwareSerial_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ static void usb_device_default()
MCF_USB_OTG_CTL |= MCF_USB_OTG_CTL_ODD_RST;
MCF_USB_OTG_CTL &= ~MCF_USB_OTG_CTL_ODD_RST;

memset(bdts, 0, BDT_RAM_SIZE);
memset((void *)bdts, 0, BDT_RAM_SIZE);
memset(endpoints, 0, sizeof(endpoints));

assert(configuration_descriptor);
Expand Down Expand Up @@ -287,7 +287,7 @@ void usb_device_enqueue(int endpoint, boolean tx, byte *buffer, int length)
odd = endpoints[endpoint].bdtodd[tx];

// initialize the bdt entry
bdt = MYBDT(endpoint, tx, odd);
bdt = (struct bdt *)MYBDT(endpoint, tx, odd);
bdt->buffer = (byte *)TF_LITTLE(KVA_TO_PA((int)buffer));
flags = TF_LITTLE(bdt->flags);
assert(! (flags & BD_FLAGS_OWN));
Expand Down
10 changes: 10 additions & 0 deletions hardware/pic32/cores/pic32/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,13 @@ size_t Print::printFloat(double number, uint8_t digits)

return n;
}

extern int _doprnt (char const *fmt, va_list ap, Print *stream);

size_t Print::printf(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
size_t r = _doprnt(fmt, args, this);
va_end(args);
return r;
}
3 changes: 3 additions & 0 deletions hardware/pic32/cores/pic32/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <inttypes.h>
#include <stdio.h> // for size_t
#include <stdarg.h>

#include "WString.h"
#include "Printable.h"
Expand Down Expand Up @@ -77,6 +78,8 @@ class Print
size_t println(double, int = 2);
size_t println(const Printable&);
size_t println(void);

size_t printf(const char *fmt, ...);
};

#endif
4 changes: 3 additions & 1 deletion hardware/pic32/cores/pic32/chipKIT-application-COMMON-MZ.ld
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,10 @@ SECTIONS
.dbg_data (NOLOAD) :
{
. += (DEFINED (_DEBUGGER) ? 0x200 : 0x0);
/* Additional data memory required for DSPr2 registers */
/* Additional data memory required for DSPr2 (EC) registers */
. += (DEFINED (_DEBUGGER) ? 0x80 : 0x0);
/* Additional data memory required for FPU (EF) registers */
. += (DEFINED (_DEBUGGER) ? 0x100 : 0x0);
} >kseg0_data_mem

.ram_exchange_data (NOLOAD) :
Expand Down
17 changes: 9 additions & 8 deletions hardware/pic32/cores/pic32/main.cpp
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
//************************************************************************
//* main.c
//*
//*
//* Arduino core files for PIC32
//* Copyright (c) 2010, 2011 by Mark Sproul
//*
//*
//*
//*
//************************************************************************
//* this code is based on code Copyright (c) 2005-2006 David A. Mellis
//*
//*
//* This library is free software; you can redistribute it and/or
//* modify it under the terms of the GNU Lesser General Public
//* License as published by the Free Software Foundation; either
//* version 2.1 of the License, or (at your option) any later version.
//*
//*
//* This library is distributed in the hope that it will be useful,
//* but WITHOUT ANY WARRANTY; without even the implied warranty of
//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.//* See the GNU
//* Lesser General Public License for more details.
//*
//*
//* You should have received a copy of the GNU Lesser General
//* Public License along with this library; if not, write to the
//* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
//* Boston, MA 02111-1307 USA
//*
//*
//*
//*
//************************************************************************
//* Edit History
//************************************************************************
Expand Down Expand Up @@ -64,3 +64,4 @@ int main(void)
}
return 0;
}

31 changes: 18 additions & 13 deletions hardware/pic32/cores/pic32/wiring_analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

uint32_t analog_reference = 0; //default to AVDD, AVSS

uint8_t pwm_active = 0; //keeps track of active PWM outputs
uint16_t pwm_active = 0; //keeps track of active PWM outputs


//*********************************************************************
Expand Down Expand Up @@ -372,7 +372,7 @@ int tmp;
void analogWrite(uint8_t pin, int val)
{
uint16_t timer;
uint8_t pwm_mask;
uint16_t pwm_mask;
p32_oc * ocp;

/* Check if pin number is in valid range.
Expand Down Expand Up @@ -485,18 +485,23 @@ int _board_analogWrite(uint8_t pin, int val);
void turnOffPWM(uint8_t timer)
{
p32_oc * ocp;
uint16_t pwm_mask = (1 << (timer - (_TIMER_OC1 >> _BN_TIMER_OC)));

/* Disable the output compare.
*/
ocp = (p32_oc *)(_OCMP1_BASE_ADDRESS + (0x200 * (timer - (_TIMER_OC1 >> _BN_TIMER_OC))));
ocp->ocxCon.clr = OCCON_ON;
// only process this if the PWM was ON
if((pwm_active & pwm_mask) != 0)
{
/* Disable the output compare.
*/
ocp = (p32_oc *)(_OCMP1_BASE_ADDRESS + (0x200 * (timer - (_TIMER_OC1 >> _BN_TIMER_OC))));
ocp->ocxCon.clr = OCCON_ON;

// Turn off the bit saying that this PWM is active.
pwm_active &= ~(1 << (timer - (_TIMER_OC1 >> _BN_TIMER_OC)));
// Turn off the bit saying that this PWM is active.
pwm_active &= ~pwm_mask;

// If no PWM are active, turn off the timer.
if (pwm_active == 0)
{
T2CONCLR = TBCON_ON;
}
// If no PWM are active, turn off the timer.
if (pwm_active == 0)
{
T2CONCLR = TBCON_ON;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,42 @@ unsigned long lastConnectionTime = 0; // last time you connected to the
boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 10*1000; //delay between updates to xively.com

// this method makes a HTTP connection to the server:
void sendData(String &thisData) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.xively.com");
client.print("X-xivelyApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
client.println(thisData.length());

// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();

// here's the actual content of the PUT request:
client.println(thisData);
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// note the time that the connection was made or attempted:
lastConnectionTime = millis();
}

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
Expand Down Expand Up @@ -116,39 +152,3 @@ void loop() {
lastConnected = client.connected();
}

// this method makes a HTTP connection to the server:
void sendData(String thisData) {
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println("connecting...");
// send the HTTP PUT request:
client.print("PUT /v2/feeds/");
client.print(FEEDID);
client.println(".csv HTTP/1.1");
client.println("Host: api.xively.com");
client.print("X-xivelyApiKey: ");
client.println(APIKEY);
client.print("User-Agent: ");
client.println(USERAGENT);
client.print("Content-Length: ");
client.println(thisData.length());

// last pieces of the HTTP PUT request:
client.println("Content-Type: text/csv");
client.println("Connection: close");
client.println();

// here's the actual content of the PUT request:
client.println(thisData);
}
else {
// if you couldn't make a connection:
Serial.println("connection failed");
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
// note the time that the connection was made or attempted:
lastConnectionTime = millis();
}

Loading

0 comments on commit 8468e59

Please sign in to comment.