From f5c1d1a3b63dc60ec105393d69c8fbf9ff7745bd Mon Sep 17 00:00:00 2001 From: Larry Standage Date: Mon, 10 Jul 2017 14:21:49 -0700 Subject: [PATCH] Initial support for Curiosity MX board. *NOTE* This disables a PPS pin combination, and needs fixing. See Issue #357. --- pic32/boards.txt | 55 ++ pic32/cores/pic32/pps/pingroups_37x47x.h | 2 +- pic32/variants/Curiosity_MX470/Board_Data.c | 727 ++++++++++++++++++++ pic32/variants/Curiosity_MX470/Board_Defs.h | 438 ++++++++++++ 4 files changed, 1221 insertions(+), 1 deletion(-) create mode 100644 pic32/variants/Curiosity_MX470/Board_Data.c create mode 100644 pic32/variants/Curiosity_MX470/Board_Defs.h diff --git a/pic32/boards.txt b/pic32/boards.txt index df382a7c..c49c734b 100644 --- a/pic32/boards.txt +++ b/pic32/boards.txt @@ -1047,3 +1047,58 @@ clicker2.build.mcu=32MX460F512L clicker2.build.f_cpu=80000000L clicker2.build.core=pic32 clicker2.build.variant=Clicker2 + +############################################################ +flipnclickmz.name=MikroElektronika Flip N Click MZ +flipnclickmz.group=MikroElektronika +flipnclickmz.platform=pic32 +flipnclickmz.build.board=_BOARD_PIC32MZ_FLIP_N_CLICK_ +flipnclickmz.ccflags=ffff +#flipnclickmz.ldscript=MZ-application-32MZ2048ECX.ld +flipnclickmz.ldcommon=chipKIT-application-COMMON-MZ.ld + +flipnclickmz.compiler.c.extra_flags= +flipnclickmz.compiler.cpp.extra_flags= +flipnclickmz.upload.protocol=stk500v2 + +flipnclickmz.upload.maximum_size=2080768 +flipnclickmz.upload.maximum_data_size=524288 +flipnclickmz.upload.speed=115200 +flipnclickmz.upload.tool=pic32prog + +flipnclickmz.bootloader.low_fuses=0xff +flipnclickmz.bootloader.high_fuses=0xdd +flipnclickmz.bootloader.extended_fuses=0x00 +#flipnclickmz.bootloader.path=not-supported +#flipnclickmz.bootloader.file=not-supported +flipnclickmz.bootloader.unlock_bits=0x3F +flipnclickmz.bootloader.lock_bits=0x0F + +flipnclickmz.build.mcu=32MZ2048EFG100 +flipnclickmz.build.f_cpu=200000000UL +flipnclickmz.build.core=pic32 +flipnclickmz.build.variant=Flip_N_Click +flipnclickmz.build.ldscript.path={build.variant.path} +#mikroe_PIC32MZFlipNClick.upload.using=avrdude1 + + +############################################################ +curiositymx.name=Microchip Curiosity PIC32MX470 +curiositymx.group=Microchip +curiositymx.platform=pic32 +curiositymx.build.board=_BOARD_MICROCHIP_CURIOSITY_PIC32MX_ +curiositymx.ccflags=ffff +curiositymx.ldscript=chipKIT-application-32MX470F512.ld + +curiositymx.build.extra_flags=-D_USE_USB_FOR_SERIAL_ + +curiositymx.upload.protocol=stk500v2 +curiositymx.upload.maximum_size=520192 +curiositymx.upload.maximum_data_size=131072 +curiositymx.upload.speed=115200 +curiositymx.upload.tool=pic32prog + +curiositymx.build.mcu=32MX470F512H +curiositymx.build.f_cpu=120000000L +curiositymx.build.core=pic32 +curiositymx.build.variant=Curiosity_MX470 diff --git a/pic32/cores/pic32/pps/pingroups_37x47x.h b/pic32/cores/pic32/pps/pingroups_37x47x.h index b90544a9..c1af342a 100644 --- a/pic32/cores/pic32/pps/pingroups_37x47x.h +++ b/pic32/cores/pic32/pps/pingroups_37x47x.h @@ -53,7 +53,7 @@ #define _PPS_RPD8 ( 4 + _PPS_SET_D) #define _PPS_RPB6 ( 5 + _PPS_SET_D) #define _PPS_RPD5 ( 6 + _PPS_SET_D) -#define _PPS_RPB2 ( 7 + _PPS_SET_D) +//#define _PPS_RPB2 ( 7 + _PPS_SET_D) #define _PPS_RPF3 ( 8 + _PPS_SET_D | _PPS_SET_B) #define _PPS_RPF13 ( 9 + _PPS_SET_D) #define _PPS_RPC2 (12 + _PPS_SET_D) diff --git a/pic32/variants/Curiosity_MX470/Board_Data.c b/pic32/variants/Curiosity_MX470/Board_Data.c new file mode 100644 index 00000000..30064eae --- /dev/null +++ b/pic32/variants/Curiosity_MX470/Board_Data.c @@ -0,0 +1,727 @@ +/************************************************************************/ +/* */ +/* Board_Data.c -- Default Board Customization Data Declarations */ +/* */ +/************************************************************************/ +/* Author: Gene Apperson */ +/* Copyright 2011, Digilent. All rights reserved */ +/************************************************************************/ +/* File Description: */ +/* */ +/* This file contains the board specific declarations and data structure*/ +/* to customize the chipKIT MPIDE for use with a generic board using a */ +/* PIC32 part in a 64-pin package. */ +/* */ +/* This code is based on earlier work: */ +/* Copyright (c) 2010, 2011 by Mark Sproul */ +/* Copyright (c) 2005, 2006 by David A. Mellis */ +/* */ +/************************************************************************/ +/* Revision History: */ +/* */ +/* 11/28/2011(GeneA): Created by splitting data out of Board_Defs.h */ +/* 03/11/2012(BrianS): Modified for Fubarino board */ +/* 02/12/2013(GeneA): removed dependency on Microchip plib library */ +/* */ +/************************************************************************/ +//* 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 +/************************************************************************/ + +#if !defined(BOARD_DATA_C) +#define BOARD_DATA_C + +#include + +/* ------------------------------------------------------------ */ +/* Data Tables */ +/* ------------------------------------------------------------ */ +/* The following declarations define data used in pin mapping. */ +/* ------------------------------------------------------------ */ + +#if defined(OPT_BOARD_DATA) + +/* ------------------------------------------------------------ */ +/* This table is used to map from port number to the address of +** the TRIS register for the port. This is used for setting the +** pin direction. +*/ +const uint32_t port_to_tris_PGM[] = { + NOT_A_PORT, //index value 0 is not used + +#if defined(_PORTA) + (uint32_t)&TRISA, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTB) + (uint32_t)&TRISB, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTC) + (uint32_t)&TRISC, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTD) + (uint32_t)&TRISD, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTE) + (uint32_t)&TRISE, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTF) + (uint32_t)&TRISF, +#else + NOT_A_PORT, +#endif + +#if defined(_PORTG) + (uint32_t)&TRISG, +#else + NOT_A_PORT, +#endif + + NOT_A_PORT, +}; + +/* ------------------------------------------------------------ */ +/* This table is used to map the digital pin number to the port +** containing that pin. The default mapping is to assign pin numbers +** for every possible port bit in order from PORTA to PORTG. +*/ +const uint8_t digital_pin_to_port_PGM[] = { + // Pins 0 through 11 on Click Socket 1 + _IOPORT_PB, // 0 RB4 + _IOPORT_PE, // 1 RE3 + _IOPORT_PD, // 2 RD4 + _IOPORT_PD, // 3 RD2 + _IOPORT_PD, // 4 RD3 + _IOPORT_PD, // 5 RD5 + _IOPORT_PB, // 6 RB14 + _IOPORT_PD, // 7 RD1 + _IOPORT_PF, // 8 RF1 + _IOPORT_PF, // 9 RF0 + _IOPORT_PD, // 10 RD10 + _IOPORT_PD, // 11 RD9 + + // Pins 12 through 23 on Click Socket 2 + _IOPORT_PB, // 12 RB11 + _IOPORT_PB, // 13 RB15 + _IOPORT_PG, // 14 RG9 + _IOPORT_PG, // 15 RG6 + _IOPORT_PG, // 16 RG7 + _IOPORT_PG, // 17 RG8 + _IOPORT_PD, // 18 RD8 + _IOPORT_PD, // 19 RD0 + _IOPORT_PB, // 20 RB9 + _IOPORT_PE, // 21 RE5 + _IOPORT_PF, // 22 RF5 + _IOPORT_PF, // 23 RF4 + + // Pins 24 through 28 on the external header and BM64 + _IOPORT_PB, // 24 RB0 + _IOPORT_PB, // 25 RB1 + _IOPORT_PB, // 26 RB2 + _IOPORT_PB, // 27 RB13 + _IOPORT_PB, // 28 RB12 + + // Pins 29 through 34 are the LEDs + _IOPORT_PE, // 29 RE4 + _IOPORT_PE, // 30 RE6 + _IOPORT_PE, // 31 RE7 + _IOPORT_PB, // 32 RB10 + _IOPORT_PB, // 33 RB3 + _IOPORT_PB, // 34 RB2 + + // Pin 35 is the Switch (S1) + _IOPORT_PD, // 35 RD6 +}; + +/* ------------------------------------------------------------ */ +/* This table is used to map from digital pin number to a bit mask +** for the corresponding bit within the port. +*/ +const uint16_t digital_pin_to_bit_mask_PGM[] = { + _BV( 4 ) , // 0 RB4 + _BV( 3 ) , // 1 RE3 + _BV( 4 ), // 2 RD4 + _BV( 2 ), // 3 RD2 + _BV( 3 ) , // 4 RD3 + _BV( 5 ), // 5 RD5 + _BV( 14 ), // 6 RB14 + _BV( 1 ) , // 7 RD1 + _BV( 1 ) , // 8 RF1 + _BV( 0 ) , // 9 RF0 + _BV( 10 ), // 10 RD10 + _BV( 9 ) , // 11 RD9 + _BV( 11 ), // 12 RB11 + _BV( 15 ), // 13 RB15 + _BV( 9 ) , // 14 RG9 + _BV( 6 ) , // 15 RG6 + _BV( 7 ) , // 16 RG7 + _BV( 8 ) , // 17 RG8 + _BV( 8 ) , // 18 RD8 + _BV( 0 ) , // 19 RD0 + _BV( 9 ) , // 20 RB9 + _BV( 5 ) , // 21 RE5 + _BV( 5 ) , // 22 RF5 + _BV( 4 ) , // 23 RF4 + _BV( 0 ) , // 24 RB0 + _BV( 1 ) , // 25 RB1 + _BV( 2 ) , // 26 RB2 + _BV( 13 ), // 27 RB13 + _BV( 12 ), // 28 RB12 + _BV( 4 ) , // 29 RE4 + _BV( 6 ) , // 30 RE6 + _BV( 7 ) , // 31 RE7 + _BV( 10 ), // 32 RB10 + _BV( 3 ) , // 33 RB3 + _BV( 2 ) , // 34 RB2 + _BV( 6 ) , // 35 RD6 +}; + +/* ------------------------------------------------------------ */ +/* This table is used to map from digital pin number to the output +** compare number, input capture number, and timer external clock +** input associated with that pin. +*/ +const uint16_t digital_pin_to_timer_PGM[] = { + _TIMER_IC1 , // 0 RD8 + _TIMER_IC2 , // 1 RD9 + _TIMER_IC3 , // 2 RD10 + _TIMER_IC4 , // 3 RD11 + _TIMER_OC1 , // 4 RD0 + NOT_ON_TIMER , // 5 RC13 + _TIMER_TCK1 , // 6 RC14 + _TIMER_OC2 , // 7 RD1 + _TIMER_OC3 , // 8 RD2 + _TIMER_OC4 , // 9 RD3 + _TIMER_OC5 | _TIMER_IC5, // 10 RD4 + NOT_ON_TIMER , // 11 RD5 + NOT_ON_TIMER , // 12 RD6 + NOT_ON_TIMER , // 13 RD7 + NOT_ON_TIMER , // 14 RF0 + NOT_ON_TIMER , // 15 RF1 + NOT_ON_TIMER , // 16 RE0 + NOT_ON_TIMER , // 17 RE2 + NOT_ON_TIMER , // 18 RE3 + NOT_ON_TIMER , // 19 RE4 + NOT_ON_TIMER , // 20 RE5 + NOT_ON_TIMER , // 21 RE6 + NOT_ON_TIMER , // 22 RE7 + NOT_ON_TIMER , // 23 RG6 + NOT_ON_TIMER , // 24 RG7 + NOT_ON_TIMER , // 25 RG8 + NOT_ON_TIMER , // 26 RG9 + NOT_ON_TIMER , // 27 RF4 + NOT_ON_TIMER , // 28 RF5 + NOT_ON_TIMER , // 29 RB5 + NOT_ON_TIMER , // 30 RB4 + NOT_ON_TIMER , // 31 RB3 + NOT_ON_TIMER , // 32 RB2 + NOT_ON_TIMER , // 33 RB1 + NOT_ON_TIMER , // 34 RB0 + NOT_ON_TIMER , // 35 RB7 + NOT_ON_TIMER , // 36 RB6 + NOT_ON_TIMER , // 37 RB8 + NOT_ON_TIMER , // 38 RB9 + NOT_ON_TIMER , // 39 RB10 + NOT_ON_TIMER , // 40 RB11 + NOT_ON_TIMER , // 41 RB12 + NOT_ON_TIMER , // 42 RB13 + NOT_ON_TIMER , // 43 RB14 + NOT_ON_TIMER , // 44 RB15 +}; + +/* ------------------------------------------------------------ */ +/* This table maps from a digital pin number to the corresponding +** analog pin number. +*/ +//#if defined(_NOT_USED_) +const uint8_t digital_pin_to_analog_PGM[] = { + _BOARD_AN4, // 0 RD8 + NOT_ANALOG_PIN, // 1 RD9 + NOT_ANALOG_PIN, // 2 RD10 + NOT_ANALOG_PIN, // 3 RD11 + NOT_ANALOG_PIN, // 4 RD0 + NOT_ANALOG_PIN, // 5 RC13 + NOT_ANALOG_PIN, // 6 RC14 + NOT_ANALOG_PIN, // 7 RD1 + NOT_ANALOG_PIN, // 8 RD2 + NOT_ANALOG_PIN, // 9 RD3 + NOT_ANALOG_PIN, // 10 RD4 + NOT_ANALOG_PIN, // 11 RD5 + _BOARD_AN11, // 12 RD6 + NOT_ANALOG_PIN, // 13 RD7 + NOT_ANALOG_PIN, // 14 RF0 + NOT_ANALOG_PIN, // 15 RF1 + NOT_ANALOG_PIN, // 16 RE0 + NOT_ANALOG_PIN, // 17 RE1 + NOT_ANALOG_PIN, // 18 RE2 + NOT_ANALOG_PIN, // 19 RE3 + NOT_ANALOG_PIN, // 20 RE4 + NOT_ANALOG_PIN, // 21 RE5 + NOT_ANALOG_PIN, // 22 RE6 + NOT_ANALOG_PIN, // 23 RE7 + NOT_ANALOG_PIN, // 24 RG6 + NOT_ANALOG_PIN, // 25 RG7 + NOT_ANALOG_PIN, // 26 RG8 + NOT_ANALOG_PIN, // 27 RG9 + NOT_ANALOG_PIN, // 28 RF4 + NOT_ANALOG_PIN, // 29 RF5 + NOT_ANALOG_PIN, // 30 RB4 A14 + NOT_ANALOG_PIN, // 31 RB3 A13 + NOT_ANALOG_PIN, // 32 RB2 A12 + NOT_ANALOG_PIN, // 33 RB1 A11 + NOT_ANALOG_PIN, // 34 RB0 A10 + NOT_ANALOG_PIN, // 35 RB7 A9 + NOT_ANALOG_PIN, // 36 RB6 A8 + NOT_ANALOG_PIN, // 37 RB8 A7 + NOT_ANALOG_PIN, // 38 RB9 A6 + NOT_ANALOG_PIN, // 39 RB10 A5 + NOT_ANALOG_PIN, // 40 RB11 A4 + NOT_ANALOG_PIN, // 41 RB12 A3 + NOT_ANALOG_PIN, // 42 RB13 A2 + NOT_ANALOG_PIN, // 43 RB14 A1 + NOT_ANALOG_PIN, // 44 RB15 A0 +}; +//#endif + +/* ------------------------------------------------------------ */ +/* This table is used to map from the analog pin number to the +** actual A/D converter channel used for that pin. +** In the default case, where there is a one-to-one mapping, this +** table isn't needed as the analogInPinToChannel() macro is defined +** to provide the mapping. +*/ +//#if defined(_NOT_USED_) +const uint8_t analog_pin_to_channel_PGM[] = { + //* Arduino Pin PIC32 Analog channel + 0, //* A0 1 to 1 mapping + 1, //* A1 +}; +//#endif + +/* ------------------------------------------------------------ */ +/* PPS Mappings */ +/* ------------------------------------------------------------ */ + + +/* ------------------------------------------------------------ */ +/* This table maps from a digital pin number to the corresponding +** PPS register. This register is used to select the peripheral output +** connected to the pin. The register is set to 0 to disconnedt the +** pin from any peripheral so it can be used as GPIO. +** For PIC32MX1xx/2xx series devices, the PPS output select registers +** are arranged as a contiguous series of 32 bit registers. This table +** treats these registers as an array of DWORDs an stores the index +** to the register. +*/ +const uint8_t digital_pin_to_pps_out_PGM[] = { + NOT_PPS_PIN, // 0 RB04 AN4/C1INB/RB4 + _PPS_OUT(_PPS_RPE3R), // 1 RE03 RPE3/CTPLS/PMD3/RE3 + _PPS_OUT(_PPS_RPD4R), // 2 RD04 RPD4/PMWR/RD4 + _PPS_OUT(_PPS_RPD2R), // 3 RD02 AN25/RPD2/SCK1/RD2 + _PPS_OUT(_PPS_RPD3R), // 4 RD03 AN26/RPD3/RD3 + _PPS_OUT(_PPS_RPD5R), // 5 RD05 RPD5/PMRD/RD5 + _PPS_OUT(_PPS_RPB14R), // 6 RB14 AN14/RPB14/CTED5/PMA1/RB14 + _PPS_OUT(_PPS_RPD1R), // 7 RD01 AN24/RPD1/RD1 + _PPS_OUT(_PPS_RPF1R), // 8 RF01 RPF1/RF1 + _PPS_OUT(_PPS_RPF0R), // 9 RF00 RPF0/RF0 + _PPS_OUT(_PPS_RPD10R), // 10 RD10 RPD10/SCL1/PMCS2/RD10 + _PPS_OUT(_PPS_RPD9R), // 11 RD09 RPD9/SDA1/RD9 + NOT_PPS_PIN, // 12 RB11 TDO/AN11/PMA12/RB11 + _PPS_OUT(_PPS_RPB15R), // 13 RB15 AN15/RPB15/OCFB/CTED6/PMA0/RB15 + _PPS_OUT(_PPS_RPG9R), // 14 RG09 AN19/C2INC/RPG9/PMA2/RG9 + _PPS_OUT(_PPS_RPG6R), // 15 RG06 AN16/C1IND/RPG6/SCK2/PMA5/RG6 + _PPS_OUT(_PPS_RPG7R), // 16 RG07 AN17/C1INC/RPG7/PMA4/RG7 + _PPS_OUT(_PPS_RPG8R), // 17 RG08 AN18/C2IND/RPG8/PMA3/RG8 + _PPS_OUT(_PPS_RPD8R), // 18 RD08 RPD8/RTCC/RD8 + _PPS_OUT(_PPS_RPD0R), // 19 RD00 RPD0/INT0/RD0 + _PPS_OUT(_PPS_RPB9R), // 20 RB09 AN9/RPB9/CTED4/PMA7/RB9 + _PPS_OUT(_PPS_RPE5R), // 21 RE05 AN22/RPE5/PMD5/RE5 + _PPS_OUT(_PPS_RPF5R), // 22 RF05 RPF5/SCL2/PMA8/RF5 + _PPS_OUT(_PPS_RPF4R), // 23 RF04 RPF4/SDA2/PMA9/RF4 + _PPS_OUT(_PPS_RPB0R), // 24 RB00 PGED1/VREF+/CVREF+/AN0/RPB0/PMA6/RB0 + _PPS_OUT(_PPS_RPB1R), // 25 RB01 PGEC1/VREF-/CVREF-/AN1/RPB1/CTED12/RB1 + _PPS_OUT(_PPS_RPB2R), // 26 RB02 PGEC3/AN2/C2INB/RPB2/CTED13/RB2 + NOT_PPS_PIN, // 27 RB13 TDI/AN13/PMA10/RB13 + NOT_PPS_PIN, // 28 RB12 TCK/AN12/PMA11/RB12 + NOT_PPS_PIN, // 29 RE04 AN21/PMD4/RE4 + NOT_PPS_PIN, // 30 RE06 AN23/PMD6/RE6 + NOT_PPS_PIN, // 31 RE07 AN27/PMD7/RE7 + _PPS_OUT(_PPS_RPB2R), // 32 RB10 TMS/CVREFOUT/AN10/RPB10/CTED11//PMA13/RB10 + _PPS_OUT(_PPS_RPB2R), // 33 RB03 PGED3/AN3/C2INA/RPB3/RB3 + _PPS_OUT(_PPS_RPB2R), // 34 RB02 PGEC3/AN2/C2INB/RPB2/CTED13/RB2 + NOT_PPS_PIN, // 35 RD06 RD6 + }; + +/* ------------------------------------------------------------ */ +/* This table maps from the digital pin number to the value to be +** loaded into a PPS input select register to select that pin. +** It also maps from digital pin number to input/output pin set to +** which the pin belongs. The set mask is in the high four bits, +** the select value is in the low four bits. +** Note: if the PIC32 device has more than four pin sets, or more than +** 16 pin mapping choices per input function, then this table will have +** to be redefined as a table of uint16_t values and the macros used to +** access the table redefined as well. +*/ +const uint8_t digital_pin_to_pps_in_PGM[] = { + NOT_PPS_PIN, // 0 RB04 AN4/C1INB/RB4 + _PPS_IN(_PPS_RPE3), // 1 RE03 RPE3/CTPLS/PMD3/RE3 + _PPS_IN(_PPS_RPD4), // 2 RD04 RPD4/PMWR/RD4 + _PPS_IN(_PPS_RPD2), // 3 RD02 AN25/RPD2/SCK1/RD2 + _PPS_IN(_PPS_RPD3), // 4 RD03 AN26/RPD3/RD3 + _PPS_IN(_PPS_RPD5), // 5 RD05 RPD5/PMRD/RD5 + _PPS_IN(_PPS_RPB14), // 6 RB14 AN14/RPB14/CTED5/PMA1/RB14 + _PPS_IN(_PPS_RPD1), // 7 RD01 AN24/RPD1/RD1 + _PPS_IN(_PPS_RPF1), // 8 RF01 RPF1/RF1 + _PPS_IN(_PPS_RPF0), // 9 RF00 RPF0/RF0 + _PPS_IN(_PPS_RPD10), // 10 RD10 RPD10/SCL1/PMCS2/RD10 + _PPS_IN(_PPS_RPD9), // 11 RD09 RPD9/SDA1/RD9 + NOT_PPS_PIN, // 12 RB11 TDO/AN11/PMA12/RB11 + _PPS_IN(_PPS_RPB15), // 13 RB15 AN15/RPB15/OCFB/CTED6/PMA0/RB15 + _PPS_IN(_PPS_RPG9), // 14 RG09 AN19/C2INC/RPG9/PMA2/RG9 + _PPS_IN(_PPS_RPG6), // 15 RG06 AN16/C1IND/RPG6/SCK2/PMA5/RG6 + _PPS_IN(_PPS_RPG7), // 16 RG07 AN17/C1INC/RPG7/PMA4/RG7 + _PPS_IN(_PPS_RPG8), // 17 RG08 AN18/C2IND/RPG8/PMA3/RG8 + _PPS_IN(_PPS_RPD8), // 18 RD08 RPD8/RTCC/RD8 + _PPS_IN(_PPS_RPD0), // 19 RD00 RPD0/INT0/RD0 + _PPS_IN(_PPS_RPB9), // 20 RB09 AN9/RPB9/CTED4/PMA7/RB9 + _PPS_IN(_PPS_RPE5), // 21 RE05 AN22/RPE5/PMD5/RE5 + _PPS_IN(_PPS_RPF5), // 22 RF05 RPF5/SCL2/PMA8/RF5 + _PPS_IN(_PPS_RPF4), // 23 RF04 RPF4/SDA2/PMA9/RF4 + _PPS_IN(_PPS_RPB0), // 24 RB00 PGED1/VREF+/CVREF+/AN0/RPB0/PMA6/RB0 + _PPS_IN(_PPS_RPB1), // 25 RB01 PGEC1/VREF-/CVREF-/AN1/RPB1/CTED12/RB1 + _PPS_IN(_PPS_RPB2), // 26 RB02 PGEC3/AN2/C2INB/RPB2/CTED13/RB2 + NOT_PPS_PIN, // 27 RB13 TDI/AN13/PMA10/RB13 + NOT_PPS_PIN, // 28 RB12 TCK/AN12/PMA11/RB12 + NOT_PPS_PIN, // 29 RE04 AN21/PMD4/RE4 + NOT_PPS_PIN, // 30 RE06 AN23/PMD6/RE6 + NOT_PPS_PIN, // 31 RE07 AN27/PMD7/RE7 + _PPS_IN(_PPS_RPB10), // 32 RB10 TMS/CVREFOUT/AN10/RPB10/CTED11//PMA13/RB10 + _PPS_IN(_PPS_RPB3), // 33 RB03 PGED3/AN3/C2INA/RPB3/RB3 + _PPS_IN(_PPS_RPB2), // 34 RB02 PGEC3/AN2/C2INB/RPB2/CTED13/RB2 + NOT_PPS_PIN, // 35 RD06 RD6 +}; + +/* ------------------------------------------------------------ */ +/* This table maps from an output compare number as stored in the +** digital_pin_to_timer_PGM table to the digital pin number of the +** pin that OC is connected to. This table is only required for +** devices that support peripheral pin select (PPS), i.e. PIC32MX1xx/2xx +** devices. +*/ + +const uint8_t output_compare_to_digital_pin_PGM[] = { + NOT_PPS_PIN, + PIN_OC1, + PIN_OC2, +}; + +/* ------------------------------------------------------------ */ +/* This table maps from an external interrupt number to the digital +** pin for that interrupt. +*/ + +const uint8_t external_int_to_digital_pin_PGM[] = { + NOT_PPS_PIN, + PIN_INT1, + PIN_INT2, +}; + + + +/* ------------------------------------------------------------ */ +/* Include Files for Board Customization Functions */ +/* ------------------------------------------------------------ */ + + +/* ------------------------------------------------------------ */ +/* Board Customization Functions */ +/* ------------------------------------------------------------ */ +/* */ +/* The following can be used to customize the behavior of some */ +/* of the core API functions. These provide hooks that can be */ +/* used to extend or replace the default behavior of the core */ +/* functions. To use one of these functions, add the desired */ +/* code to the function skeleton below and then set the value */ +/* of the appropriate compile switch above to 1. This will */ +/* cause the hook function to be compiled into the build and */ +/* to cause the code to call the hook function to be compiled */ +/* into the appropriate core function. */ +/* */ +/* ------------------------------------------------------------ */ +/*** _board_init +** +** Parameters: +** none +** +** Return Value: +** none +** +** Errors: +** none +** +** Description: +** This function is called from the core init() function. +** This can be used to perform any board specific init +** that needs to be done when the processor comes out of +** reset and before the user sketch is run. +*/ +#if (OPT_BOARD_INIT != 0) + +void _board_init(void) { + + /* Turn off Secondary oscillator so pins can be used as GPIO + */ + OSCCONCLR = _OSCCON_SOSCEN_MASK; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_pinMode +** +** Parameters: +** pin - digital pin number to configure +** mode - mode to which the pin should be configured +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the pinMode +** function. It can perform any special processing needed +** when setting the pin mode. If this function returns zero, +** control will pass through the normal pinMode code. If +** it returns a non-zero value the normal pinMode code isn't +** executed. +*/ +#if (OPT_BOARD_DIGITAL_IO != 0) + +int _board_pinMode(uint8_t pin, uint8_t mode) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_getPinMode +** +** Parameters: +** pin - digital pin number +** mode - pointer to variable to receive mode value +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the getPinMode +** function. It can perform any special processing needed +** when getting the pin mode. If this function returns zero, +** control will pass through the normal getPinMode code. If +** it returns a non-zero value the normal getPinMode code isn't +** executed. +*/ +#if (OPT_BOARD_DIGITAL_IO != 0) + +int _board_getPinMode(uint8_t pin, uint8_t * mode) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_digitalWrite +** +** Parameters: +** pin - digital pin number +** val - value to write to the pin +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the digitalWrite +** function. It can perform any special processing needed +** in writing to the pin. If this function returns zero, +** control will pass through the normal digitalWrite code. If +** it returns a non-zero value the normal digitalWrite code isn't +** executed. +*/#if (OPT_BOARD_DIGITAL_IO != 0) + +int _board_digitalWrite(uint8_t pin, uint8_t val) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_digitalRead +** +** Parameters: +** pin - digital pin number +** val - pointer to variable to receive pin value +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the digitalRead +** function. It can perform any special processing needed +** in reading from the pin. If this function returns zero, +** control will pass through the normal digitalRead code. If +** it returns a non-zero value the normal digitalRead code isn't +** executed. +*/ +#if (OPT_BOARD_DIGITAL_IO != 0) + +int _board_digitalRead(uint8_t pin, uint8_t * val) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_analogRead +** +** Parameters: +** pin - analog channel number +** val - pointer to variable to receive analog value +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the analogRead +** function. It can perform any special processing needed +** in reading from the pin. If this function returns zero, +** control will pass through the normal analogRead code. If +** it returns a non-zero value the normal analogRead code isn't +** executed. +*/ +#if (OPT_BOARD_ANALOG_READ != 0) + +int _board_analogRead(uint8_t pin, int * val) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_analogReference +** +** Parameters: +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the analogReference +** function. It can perform any special processing needed +** to set the reference voltage. If this function returns zero, +** control will pass through the normal analogReference code. If +** it returns a non-zero value the normal analogReference code isn't +** executed. +*/ +#if (OPT_BOARD_ANALOG_READ != 0) + +int _board_analogReference(uint8_t mode) { + + return 0; + +} + +#endif + +/* ------------------------------------------------------------ */ +/*** _board_analogWrite +** +** Parameters: +** pin - pin number +** val - analog value to write +** +** Return Value: +** Returns 0 if not handled, !0 if handled. +** +** Errors: +** none +** +** Description: +** This function is called at the beginning of the analogWrite +** function. It can perform any special processing needed +** in writing to the pin. If this function returns zero, +** control will pass through the normal analogWrite code. If +** it returns a non-zero value the normal analogWrite code isn't +** executed. +*/ +#if (OPT_BOARD_ANALOG_WRITE != 0) + +int _board_analogWrite(uint8_t pin, int val) { + + return 0; + +} + +#endif + +#endif // OPT_BOARD_DATA + +/* ------------------------------------------------------------ */ + +#endif // BOARD_DATA_C + +/************************************************************************/ diff --git a/pic32/variants/Curiosity_MX470/Board_Defs.h b/pic32/variants/Curiosity_MX470/Board_Defs.h new file mode 100644 index 00000000..8b85fba6 --- /dev/null +++ b/pic32/variants/Curiosity_MX470/Board_Defs.h @@ -0,0 +1,438 @@ +/************************************************************************/ +/* */ +/* Board_Defs.h -- Default Board Customization Declarations */ +/* */ +/************************************************************************/ +/* Author: Gene Apperson */ +/* Copyright 2011, Digilent. All rights reserved */ +/************************************************************************/ +/* File Description: */ +/* */ +/* This file contains the board specific declarations and data structure*/ +/* to customize the chipKIT MPIDE for use with a generic board using a */ +/* PIC32 part in a 64-pin package. */ +/* */ +/* This code is based on earlier work: */ +/* Copyright (c) 2010, 2011 by Mark Sproul */ +/* Copyright (c) 2005, 2006 by David A. Mellis */ +/* */ +/************************************************************************/ +/* Revision History: */ +/* */ +/* 10/07/2011(GeneA): Created */ +/* 11/28/2011(GeneA): Moved data definitions and configuration */ +/* functions to Board_Data.c */ +/* 11/29/2011(GeneA): Moved int priority definitions to System_Defs.h */ +/* 03/11/2012(BrianS): Modified for Fubarino board */ +/* */ +/************************************************************************/ +//* 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 +/************************************************************************/ + +#if !defined(BOARD_DEFS_H) +#define BOARD_DEFS_H + +#include + +/* ------------------------------------------------------------ */ +/* Public Board Declarations */ +/* ------------------------------------------------------------ */ +/* The following define symbols that can be used in a sketch to +** refer to peripherals on the board generically. +*/ + +#define _BOARD_NAME_ "CuriosityMX470" + +/* Define the peripherals available on the board. +*/ +#define NUM_DIGITAL_PINS 36 +#define NUM_ANALOG_PINS 2 +#define NUM_OC_PINS 2 +#define NUM_IC_PINS 2 +#define NUM_TCK_PINS 2 +#define NUM_INT_PINS 2 + +#define NUM_SERIAL_PORTS 2 +#define NUM_SPI_PORTS 2 +#define NUM_I2C_PORTS 2 + +#if defined(__32MX470F512H__) + #define NUM_DSPI_PORTS 2 +#else + #define NUM_DSPI_PORTS 1 +#endif +#define NUM_DTWI_PORTS 2 + +/* Define I/O devices on the board. +*/ +#define NUM_LED 6 +#define NUM_BTN 1 +#define NUM_SWT 0 +#define NUM_SERVO 0 + +/* ------------------------------------------------------------ */ +/* LED Declarations */ +/* ------------------------------------------------------------ */ + +/* Define the pin numbers for the LEDs +*/ +#define PIN_LED1 29 +#define PIN_LED2 30 +#define PIN_LED3 31 +#define PIN_LED_R 32 +#define PIN_LED_G 33 +#define PIN_LED_B 34 + +/* ------------------------------------------------------------ */ +/* Button Declarations */ +/* ------------------------------------------------------------ */ + +/* One button (PRG) for this board +*/ +#define PIN_BTN1 35 +/* Also define the virtual program button for soft reset */ +#define USE_VIRTUAL_PROGRAM_BUTTON 1 +#define VIRTUAL_PROGRAM_BUTTON_TRIS TRISDbits.TRISD6 +#define VIRTUAL_PROGRAM_BUTTON LATDbits.LATD6 + +/* ------------------------------------------------------------ */ +/* Switch Declarations */ +/* ------------------------------------------------------------ */ + +/* No switches on this board. +*/ + +/* ------------------------------------------------------------ */ +/* Servo Pin Declarations */ +/* ------------------------------------------------------------ */ + +/* No servo connectors on this board. +*/ + +/* ------------------------------------------------------------ */ +/* Timer Pin Declarations */ +/* ------------------------------------------------------------ */ + +#define PIN_OC1 6 +#define PIN_OC2 16 + +#define PIN_IC1 1 +#define PIN_IC2 2 +#define PIN_IC3 3 +#define PIN_IC4 4 +#define PIN_IC5 11 + +#define PIN_TCK1 6 +//#define PIN_TCK2 not available on the chip +//#define PIN_TCK3 not available on the chip +//#define PIN_TCK4 not available on the chip +//#define PIN_TCK5 not available on the chip + +/* ------------------------------------------------------------ */ +/* Interrupt Pin Declarations */ +/* ------------------------------------------------------------ */ + +#define PIN_INT0 17 +#define PIN_INT1 7 +#define PIN_INT2 1 + +/* ------------------------------------------------------------ */ +/* SPI Pin Declarations */ +/* ------------------------------------------------------------ */ +/* These symbols are defined for compatibility with the original +** SPI library and the original pins_arduino.h. SPI2 is used for +** the default SPI port as it's pin numbers stay constant on all +** devices. +*/ +static const uint8_t SS = 2; // PIC32 SS1 +static const uint8_t MOSI = 5; // PIC32 SDO1 +static const uint8_t MISO = 4; // PIC32 SDI1 +static const uint8_t SCK = 3; // PIC32 SCK1 + +/* The Digilent DSPI library uses these ports. +*/ +#define PIN_DSPI0_SS 2 +#define PIN_DSPI1_SS 12 + +/* ------------------------------------------------------------ */ +/* Analog Pins */ +/* ------------------------------------------------------------ */ +/* Define symbols for accessing the analog pins. This table is +** used to map an analog pin number to the corresponding digital +** pin number. +*/ +#define A0 0 +#define A1 10 + +/* ------------------------------------------------------------ */ +/* Change Notice Pins */ +/* ------------------------------------------------------------ */ +/* These define the pin numbers for the various change notice +** pins. +*/ +#define PIN_CN0 6 // RC14 +#define PIN_CN1 5 // RC13 +#define PIN_CN2 34 // RB0 +#define PIN_CN3 33 // RB1 +#define PIN_CN4 32 // RB2 +#define PIN_CN5 31 // RB3 +#define PIN_CN6 30 // RB4 +/* RB5 not brought out on Fubarino SD */ // #define PIN_CN7 29 // RB5 +#define PIN_CN8 24 // RG6 +#define PIN_CN9 25 // RG7 +#define PIN_CN10 26 // RG8 +#define PIN_CN11 27 // RG9 +#define PIN_CN12 44 // RB15 +#define PIN_CN13 10 // RD4 +#define PIN_CN14 11 // RD5 +#define PIN_CN15 12 // RD6 +#define PIN_CN16 13 // RD7 +#define PIN_CN17 28 // RF4 +#define PIN_CN18 29 // RF5 + +/* ------------------------------------------------------------ */ +/* Pin Mapping Macros */ +/* ------------------------------------------------------------ */ +/* Macros used to access the port and pin mapping tables. +** These are mostly generic, but some of them may be board specific. +** These perform slightly better as macros compared to inline functions +*/ +#define digitalPinToPort(P) ( digital_pin_to_port_PGM[P] ) +#define digitalPinToBitMask(P) ( digital_pin_to_bit_mask_PGM[P] ) +#define digitalPinToTimerOC(P) ( (digital_pin_to_timer_PGM[P] & _MSK_TIMER_OC) ) +#define digitalPinToTimerIC(P) ( (digital_pin_to_timer_PGM[P] & _MSK_TIMER_IC) ) +#define digitalPinToTimerTCK(P) ( (digital_pin_to_timer_PGM[P] & _MSK_TIMER_TCK) ) +#define digitalPinToTimer(P) digitalPinToTimerOC(P) +#define portModeRegister(P) ( (volatile uint32_t *)port_to_tris_PGM[P] ) +#define portInputRegister(P) ( (volatile uint32_t *)(port_to_tris_PGM[P] + 0x0010) ) +#define portOutputRegister(P) ( (volatile uint32_t *)(port_to_tris_PGM[P] + 0x0020) ) + +// This definition can be used for the default mapping. +//#define digitalPinToAnalog(P) ( (((P) > 15) && ((P) < 32)) ? (P)-16 : NOT_ANALOG_PIN ) +// This definition can be used for the non-default case where there +// is a mapping table to go from digital pin to analog pin +#undef digitalPinToAnalog +#define digitalPinToAnalog(P) ( ((P) > 14 ) ? digital_pin_to_analog_PGM[P] : digital_pin_to_analog_PGM[(14 - P) + 30] ) + +// This definition can be used for the default one-to-one mapping +//#define analogInPinToChannel(P) ( P ) +// This definition is used when there isn't a one-to-one mapping +// This uses a table to do the mapping. +#undef analogInPinToChannel +#define analogInPinToChannel(P) ( analog_pin_to_channel_PGM[P] ) + +/* ------------------------------------------------------------ */ +/* Data Definitions */ +/* ------------------------------------------------------------ */ + +/* The following declare externals to access the pin mapping +** tables. +*/ + +#if !defined(OPT_BOARD_DATA) + +extern const uint32_t port_to_tris_PGM[]; +extern const uint8_t digital_pin_to_port_PGM[]; +extern const uint16_t digital_pin_to_bit_mask_PGM[]; +extern const uint16_t digital_pin_to_timer_PGM[]; + +//#if defined(_NOT_USED_) +extern const uint8_t digital_pin_to_analog_PGM[]; +//#endif + +//#if defined(_NOT_USED_) +extern const uint8_t analog_pin_to_channel_PGM[]; +//#endif + +extern const uint8_t output_compare_to_digital_pin_PGM[]; +extern const uint8_t external_int_to_digital_pin_PGM[]; + +extern const uint8_t digital_pin_to_pps_out_PGM[]; +extern const uint8_t digital_pin_to_pps_in_PGM[]; + +#endif + +/* ------------------------------------------------------------ */ +/* Internal Declarations */ +/* ------------------------------------------------------------ */ +/* The following declarations are used to map peripherals for */ +/* the core and libraries and to provide configuration options */ +/* for the core. They are not normally needed by a user sketch. */ +/* ------------------------------------------------------------ */ + +#if defined(OPT_BOARD_INTERNAL) + +/* ------------------------------------------------------------ */ +/* Core Configuration Declarations */ +/* ------------------------------------------------------------ */ +/* */ +/* These are conditional compilation switches that control the */ +/* board core configuration functions. These functions provide */ +/* hooks that can call from some of the core functions into */ +/* functions defined below that can be used to extend or */ +/* replace the default behavior of the core function. To use */ +/* this, enter the appropriate code into the appropriate */ +/* function skeleton below and then set the appropriate switch */ +/* value to 1. This will cause the configuration function to be */ +/* compiled into the build and will cause the code to call the */ +/* hook function to be compiled into the core function. */ +/* */ +/* ------------------------------------------------------------ */ + +#define OPT_BOARD_INIT 1 //board needs special init code +#define OPT_BOARD_DIGITAL_IO 0 //board does not extend digital i/o functions +#define OPT_BOARD_ANALOG_READ 0 //board does not extend analogRead +#define OPT_BOARD_ANALOG_WRITE 0 //board does not extend analogWrite + +#endif // OPT_BOARD_INTERNAL + +/* ------------------------------------------------------------ */ +/* Serial Port Declarations */ +/* ------------------------------------------------------------ */ + +/* Serial port 0 uses UART1 +*/ +#define _SER0_BASE _UART1_BASE_ADDRESS +#define _SER0_IRQ _UART1_ERR_IRQ +#define _SER0_VECTOR _UART_1_VECTOR +#define _SER0_IPL_ISR IPL2SOFT +#define _SER0_IPL 2 +#define _SER0_SPL 0 +#define _SER0_TX_OUT PPS_OUT_U1TX // (RPF8R = 0b0010) RF8 -> U4TX +#define _SER0_TX_PIN 9 // REBIRDY2/RPF8/SCL3/RF8 +#define _SER0_RX_IN PPS_IN_U1RX // (U4RXR = 0b1011) RPF2 -> U4RX +#define _SER0_RX_PIN 8 // EBIRDY3/RPF2/SDA3/RF2 + +/* Serial port 1 uses UART2 +*/ +#define _SER1_BASE _UART2_BASE_ADDRESS +#define _SER1_IRQ _UART2_ERR_IRQ +#define _SER1_VECTOR _UART_2_VECTOR +#define _SER1_IPL_ISR IPL2SOFT +#define _SER1_IPL 2 +#define _SER1_SPL 0 +#define _SER1_TX_OUT PPS_OUT_U2TX // (RPF8R = 0b0010) RF8 -> U4TX +#define _SER1_TX_PIN 21 // REBIRDY2/RPF8/SCL3/RF8 +#define _SER1_RX_IN PPS_IN_U2RX // (U4RXR = 0b1011) RPF2 -> U4RX +#define _SER1_RX_PIN 20 // EBIRDY3/RPF2/SDA3/RF2 + +/* ------------------------------------------------------------ */ +/* SPI Port Declarations */ +/* ------------------------------------------------------------ */ + +/* The Digilent DSPI and standard SPI libraries uses these ports. + * SPI = DSPI0 = PIC32 HW SPI2 + * SCK = pin 24, MISO = pin 25, MOSI = pin 26, SS = pin 27 */ +#define _DSPI0_BASE _SPI2_BASE_ADDRESS +#define _DSPI0_ERR_IRQ _SPI2_ERR_IRQ +#define _DSPI0_RX_IRQ _SPI2_RX_IRQ +#define _DSPI0_TX_IRQ _SPI2_TX_IRQ +#define _DSPI0_VECTOR _SPI_2_VECTOR +#define _DSPI0_IPL_ISR IPL3SOFT +#define _DSPI0_IPL 3 +#define _DSPI0_SPL 0 + +#if defined(__32MX795F512H__) +/* DSPI1 = PIC32 HW SPI3 + * SCK = pin 7, MISO = pin 8, MOSI = pin 9, SS = pin 1 */ +#define _DSPI1_BASE _SPI3_BASE_ADDRESS +#define _DSPI1_ERR_IRQ _SPI3_ERR_IRQ +#define _DSPI1_RX_IRQ _SPI3_RX_IRQ +#define _DSPI1_TX_IRQ _SPI3_TX_IRQ +#define _DSPI1_VECTOR _SPI_3_VECTOR +#define _DSPI1_IPL_ISR IPL3SOFT +#define _DSPI1_IPL 3 +#define _DSPI1_SPL 0 + +/* DSPI2 = PIC32 HW SPI4 + * SCK = pin 43, MISO = pin 28, MOSI = pin 29, SS = pin 37 */ +#define _DSPI2_BASE _SPI4_BASE_ADDRESS +#define _DSPI2_ERR_IRQ _SPI4_ERR_IRQ +#define _DSPI2_RX_IRQ _SPI4_RX_IRQ +#define _DSPI2_TX_IRQ _SPI4_TX_IRQ +#define _DSPI2_VECTOR _SPI_4_VECTOR +#define _DSPI2_IPL_ISR IPL3SOFT +#define _DSPI2_IPL 3 +#define _DSPI2_SPL 0 +#endif + +/* ------------------------------------------------------------ */ +/* I2C Port Declarations */ +/* ------------------------------------------------------------ */ + +/* The standard I2C port uses I2C1 (SCL1/SDA1). These come to pins +** A4/A5 on the analog connector. It is necessary to have jumpers +** JP6/JP8 set appropriately (RG2/RG3 position) to access the I2C +** signals. +*/ +#define _TWI_BASE _I2C1_BASE_ADDRESS +#define _TWI_BUS_IRQ _I2C1_BUS_IRQ +#define _TWI_SLV_IRQ _I2C1_SLAVE_IRQ +#define _TWI_MST_IRQ _I2C1_MASTER_IRQ +#define _TWI_VECTOR _I2C_1_VECTOR +#define _TWI_IPL_ISR IPL3SOFT +#define _TWI_IPL 3 +#define _TWI_SPL 0 + +/* Declarations for Digilent DTWI library. +** DTWI0 is on 1/2 +** DTWI1 is on digital pins 29/28 +*/ +#define _DTWI0_BASE _I2C1_BASE_ADDRESS +#define _DTWI0_BUS_IRQ _I2C1_BUS_IRQ +#define _DTWI0_VECTOR _I2C_1_VECTOR +#define _DTWI0_IPL_ISR IPL3SOFT +#define _DTWI0_IPL 3 +#define _DTWI0_SPL 0 +#define _DTWI0_SCL_PIN 2 +#define _DTWI0_SDA_PIN 1 + + +#if defined(__32MX795F512H__) +#define _DTWI1_BASE _I2C5_BASE_ADDRESS +#define _DTWI1_BUS_IRQ _I2C5_BUS_IRQ +#define _DTWI1_VECTOR _I2C_5_VECTOR +#define _DTWI1_IPL_ISR IPL3SOFT +#define _DTWI1_IPL 3 +#define _DTWI1_SPL 0 +#define _DTWI1_SCL_PIN 29 +#define _DTWI1_SDA_PIN 28 +#else +#define _DTWI1_BASE _I2C2_BASE_ADDRESS +#define _DTWI1_BUS_IRQ _I2C2_BUS_IRQ +#define _DTWI1_VECTOR _I2C_2_VECTOR +#define _DTWI1_IPL_ISR IPL3SOFT +#define _DTWI1_IPL 3 +#define _DTWI1_SPL 0 +#define _DTWI1_SCL_PIN 29 +#define _DTWI1_SDA_PIN 28 +#endif + +/* ------------------------------------------------------------ */ +/* A/D Converter Declarations */ +/* ------------------------------------------------------------ */ + + +/* ------------------------------------------------------------ */ + +#define DefineSDSPI(spi) DSPI0 spi +#define DefineDSDVOL(vol, spi) DSDVOL vol(spi, 25) // Create an DSDVOL object + +/* ------------------------------------------------------------ */ + +#endif // BOARD_DEFS_H + +/************************************************************************/