 /* config.h - basic configuration file for lfxmit version 2.
 *  Copyright (C) 2022 by Jed Marti
 *   This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see https://www.gnu.org/licenses/.
 */
#ifndef config_h
#define config_h

// For Logo.
#define PROCESSOR "C8051F380"
#define BOARD "V2"

#define PROC_X

// System clock rate.
#define SYSCLK 48000000

// Serial port baud rate.
#define UART0_BAUD_RATE 115200

// I2C transfer rate.
#define I2CRATE 100000

// LEDs
// SPI/I2C data flash activity. Normally a RED led.
#define LED0 P1_0

// Serial port activity.
#define LED1 P1_1

// DS1085 activity (I2C)
#define LED2 P1_2

// Morse code.
#define LED3 P1_3

// All LEDs.
#define LEDS P1

// DS1085 control.
#define CTRL0 P2_0
#define CTRL1 P2_1

// Morse code.
#define MORSE P2_2

// Gives us 1 milliecond interrupts at 48 MHz.
#define RELOAD 65535 - 4000

// ET3 mask (for timer 3).
#define ET3 0x80

// The SPI chip select pin.
#define SPI_CS P0_3

// A/D channels
#define AD0    0x10
#define AD0P   0x04
#define AD1    0x20
#define AD1P   0x05
#define ADMDIN P1MDIN
#define ADSKIP P1SKIP

// Temperature constants as determined by experiment. See circuit.tex.
#ifdef PROC_A
  #define TempOffset    260.317f
  #define TempSlope     0.600542f
#elif defined(PROC_B)
  #define TempOffset    251.867f
  #define TempSlope     0.6133f
#elif defined(PROC_C)
  #define TempOffset    267.473f
  #define TempSlope     0.630284f
#else
  // Averages of above.
  #define TempOffset    259.886
  #define TempSlope     0.614709
#endif

// GPIO channels by bit number.
#define dig0    0x08
#define dig0bit P2_3
#define dig1    0x10
#define dig1bit P2_4

#endif


// EOF
