Newer
Older
/*****************************************************************************************************
* PIN LAYOUT
* This file is used by other classes to define the pins used for the hardware.
*****************************************************************************************************/
#ifndef CONFIGURATION_H
#define CONFIGURATION_H
#include <Arduino.h>
/* Runtime Configuration */
/* Debug Options */
#define DEBUG 0
/* Serial Options */
#define BAUDRATE 115200
#define PING '1'
#define MOTORPING_ON '2'
#define MOTORPING_OFF '3'
/* =================================== */
/* Pin layout */
/* =================================== */
/* Motor Pins */
#define VIBRATION_PIN 28
/* Potentiometer Pins */
#define POT0_PIN A3
/* LED Pins */
#define LED_BUILTIN 13
#define SWITCH_PIN1 51
#define SWITCH_PIN2 52
#define SWITCH_PIN3 53
/* ACCELEROMETER Pins */
#define XACC_PIN A0
#define YACC_PIN A1
#define ZACC_PIN A2
/* =================================== */
/* Resolution */
/* =================================== */
#define ADC_RES 1024
/* Buffer len */
/* typedef union */
typedef struct {
union {
uint16_t pin_vals[3];
struct {
uint16_t pin1_val;
uint16_t pin2_val;
uint16_t pin3_val;
};
};
} uint16_vec;
// Packed attribute specifies each member of the structure or union is placed
// to minimize the memory required.
// 1 byte is 16 bits
// Size: 8 bytes + header bytes(2) + chksum byte + end bytes(2)
typedef struct {
uint16_vec dip_val; // dip switch val
uint16_vec acc_val; // accelerometer val
uint16_t pot_val; // potentiometer val
uint16_t vm_val; // vibration motor out
} __attribute__((__packed__)) int_packet;