Use new attribute macros in more places

This commit is contained in:
Scott Lahteine 2017-05-22 13:47:43 -05:00
parent 85b967657e
commit 34cfbc90cd
6 changed files with 55 additions and 67 deletions

View File

@ -29,12 +29,12 @@
#define XYZ 3
#define FORCE_INLINE __attribute__((always_inline)) inline
#define _O0 __attribute__((optimize("O0")))
#define _Os __attribute__((optimize("Os")))
#define _O1 __attribute__((optimize("O1")))
#define _O2 __attribute__((optimize("O2")))
#define _O3 __attribute__((optimize("O3")))
#define _UNUSED __attribute__((unused))
#define _O0 __attribute__((optimize("O0")))
#define _Os __attribute__((optimize("Os")))
#define _O1 __attribute__((optimize("O1")))
#define _O2 __attribute__((optimize("O2")))
#define _O3 __attribute__((optimize("O3")))
// Bracket code that shouldn't be interrupted
#ifndef CRITICAL_SECTION_START

View File

@ -12,9 +12,9 @@
* @param strokes number of strokes to execute
*/
void Nozzle::stroke(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &end,
__attribute__((unused)) uint8_t const &strokes
_UNUSED point_t const &start,
_UNUSED point_t const &end,
_UNUSED uint8_t const &strokes
) {
#if ENABLED(NOZZLE_CLEAN_FEATURE)
@ -56,10 +56,10 @@ void Nozzle::stroke(
* @param objects number of objects to create
*/
void Nozzle::zigzag(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &end,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) uint8_t const &objects
_UNUSED point_t const &start,
_UNUSED point_t const &end,
_UNUSED uint8_t const &strokes,
_UNUSED uint8_t const &objects
) {
#if ENABLED(NOZZLE_CLEAN_FEATURE)
const float A = nozzle_clean_horizontal ? nozzle_clean_height : nozzle_clean_length, // [twice the] Amplitude
@ -114,10 +114,10 @@ void Nozzle::zigzag(
* @param radius radius of circle
*/
void Nozzle::circle(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &middle,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) float const &radius
_UNUSED point_t const &start,
_UNUSED point_t const &middle,
_UNUSED uint8_t const &strokes,
_UNUSED float const &radius
) {
#if ENABLED(NOZZLE_CLEAN_FEATURE)
if (strokes == 0) return;
@ -177,10 +177,10 @@ void Nozzle::circle(
* @param argument depends on the cleaning pattern
*/
void Nozzle::clean(
__attribute__((unused)) uint8_t const &pattern,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) float const &radius,
__attribute__((unused)) uint8_t const &objects
_UNUSED uint8_t const &pattern,
_UNUSED uint8_t const &strokes,
_UNUSED float const &radius,
_UNUSED uint8_t const &objects
) {
#if ENABLED(NOZZLE_CLEAN_FEATURE)
#if ENABLED(DELTA)
@ -209,7 +209,7 @@ void Nozzle::clean(
}
void Nozzle::park(
__attribute__((unused)) uint8_t const &z_action
_UNUSED uint8_t const &z_action
) {
#if ENABLED(NOZZLE_PARK_FEATURE)
float const z = current_position[Z_AXIS];

View File

@ -50,10 +50,10 @@ class Nozzle {
* @param strokes number of strokes to execute
*/
static void stroke(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &end,
__attribute__((unused)) uint8_t const &strokes
) __attribute__((optimize ("Os")));
_UNUSED point_t const &start,
_UNUSED point_t const &end,
_UNUSED uint8_t const &strokes
) _Os;
/**
* @brief Zig-zag clean pattern
@ -65,11 +65,11 @@ class Nozzle {
* @param objects number of objects to create
*/
static void zigzag(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &end,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) uint8_t const &objects
) __attribute__((optimize ("Os")));
_UNUSED point_t const &start,
_UNUSED point_t const &end,
_UNUSED uint8_t const &strokes,
_UNUSED uint8_t const &objects
) _Os;
/**
* @brief Circular clean pattern
@ -80,11 +80,11 @@ class Nozzle {
* @param radius radius of circle
*/
static void circle(
__attribute__((unused)) point_t const &start,
__attribute__((unused)) point_t const &middle,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) float const &radius
) __attribute__((optimize ("Os")));
_UNUSED point_t const &start,
_UNUSED point_t const &middle,
_UNUSED uint8_t const &strokes,
_UNUSED float const &radius
) _Os;
public:
/**
@ -95,15 +95,15 @@ class Nozzle {
* @param argument depends on the cleaning pattern
*/
static void clean(
__attribute__((unused)) uint8_t const &pattern,
__attribute__((unused)) uint8_t const &strokes,
__attribute__((unused)) float const &radius,
__attribute__((unused)) uint8_t const &objects = 0
) __attribute__((optimize ("Os")));
_UNUSED uint8_t const &pattern,
_UNUSED uint8_t const &strokes,
_UNUSED float const &radius,
_UNUSED uint8_t const &objects = 0
) _Os;
static void park(
__attribute__((unused)) uint8_t const &z_action
) __attribute__((optimize ("Os")));
_UNUSED uint8_t const &z_action
) _Os;
};
#endif

View File

@ -27,37 +27,26 @@
#include "softspi.h"
template<uint8_t MisoPin, uint8_t MosiPin, uint8_t SckPin>
class Spi {
static SoftSPI<MisoPin, MosiPin, SckPin> softSpi;
class SPI {
static SoftSPI<MisoPin, MosiPin, SckPin> softSPI;
public:
inline __attribute__((always_inline))
static void init() {
softSpi.begin();
}
inline __attribute__((always_inline))
static void send(uint8_t data) {
softSpi.send(data);
}
inline __attribute__((always_inline))
static uint8_t receive() {
return softSpi.receive();
}
FORCE_INLINE static void init() { softSPI.begin(); }
FORCE_INLINE static void send(uint8_t data) { softSPI.send(data); }
FORCE_INLINE static uint8_t receive() { return softSPI.receive(); }
};
//hardware spi
// Hardware SPI
template<>
class Spi<MISO_PIN, MOSI_PIN, SCK_PIN> {
class SPI<MISO_PIN, MOSI_PIN, SCK_PIN> {
public:
inline __attribute__((always_inline))
static void init() {
FORCE_INLINE static void init() {
OUT_WRITE(SCK_PIN, LOW);
OUT_WRITE(MOSI_PIN, HIGH);
SET_INPUT(MISO_PIN);
WRITE(MISO_PIN, HIGH);
}
inline __attribute__((always_inline))
static uint8_t receive() {
FORCE_INLINE static uint8_t receive() {
SPDR = 0;
for (;!TEST(SPSR, SPIF););
return SPDR;
@ -65,4 +54,4 @@ class Spi<MISO_PIN, MOSI_PIN, SCK_PIN> {
};
#endif
#endif // __SPI_H__

View File

@ -935,7 +935,7 @@ void Temperature::updateTemperaturesFromRawValues() {
#ifndef MAX6675_DO_PIN
#define MAX6675_DO_PIN MISO_PIN
#endif
Spi<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
SPI<MAX6675_DO_PIN, MOSI_PIN, MAX6675_SCK_PIN> max6675_spi;
#endif
/**

View File

@ -288,8 +288,7 @@ class Temperature {
/**
* Call periodically to manage heaters
*/
//static void manage_heater(); // changed to address compiler error
static void manage_heater() __attribute__((__optimize__("O2")));
static void manage_heater() _O2; // Added _O2 to work around a compiler error
/**
* Preheating hotends