Tweaks to HAL format and order

This commit is contained in:
Scott Lahteine
2018-09-28 15:57:21 -05:00
parent b682a1961a
commit ad21a4f07b
3 changed files with 61 additions and 52 deletions

View File

@ -64,10 +64,11 @@ extern "C" volatile uint32_t _millis;
#include "../shared/HAL_SPI.h"
#include "fastio.h"
#include "watchdog.h"
#include "serial.h"
#include "HAL_timers.h"
#include "HardwareSerial.h"
//
// Default graphical display delays
//
#ifndef ST7920_DELAY_1
#define ST7920_DELAY_1 DELAY_NS(600)
#endif
@ -78,6 +79,12 @@ extern "C" volatile uint32_t _millis;
#define ST7920_DELAY_3 DELAY_NS(750)
#endif
//
// Arduino-style serial ports
//
#include "serial.h"
#include "HardwareSerial.h"
extern HalSerial usb_serial;
#if !WITHIN(SERIAL_PORT, -1, 3)
@ -126,24 +133,34 @@ extern HalSerial usb_serial;
#define NUM_SERIAL 1
#endif
//
// Interrupts
//
#define CRITICAL_SECTION_START uint32_t primask = __get_PRIMASK(); __disable_irq()
#define CRITICAL_SECTION_END if (!primask) __enable_irq()
#define ISRS_ENABLED() (!__get_PRIMASK())
#define ENABLE_ISRS() __enable_irq()
#define DISABLE_ISRS() __disable_irq()
//Utility functions
//
// Utility functions
//
int freeMemory(void);
// SPI: Extended functions which take a channel number (hardware SPI only)
/** Write single byte to specified SPI channel */
//
// SPI: Extended functions taking a channel number (Hardware SPI only)
//
// Write single byte to specified SPI channel
void spiSend(uint32_t chan, byte b);
/** Write buffer to specified SPI channel */
// Write buffer to specified SPI channel
void spiSend(uint32_t chan, const uint8_t* buf, size_t n);
/** Read single byte from specified SPI channel */
// Read single byte from specified SPI channel
uint8_t spiRec(uint32_t chan);
//
// ADC
//
#define HAL_ANALOG_SELECT(pin) HAL_adc_enable_channel(pin)
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC() HAL_adc_get_result()