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 XYZ 3
#define FORCE_INLINE __attribute__((always_inline)) inline #define FORCE_INLINE __attribute__((always_inline)) inline
#define _UNUSED __attribute__((unused))
#define _O0 __attribute__((optimize("O0"))) #define _O0 __attribute__((optimize("O0")))
#define _Os __attribute__((optimize("Os"))) #define _Os __attribute__((optimize("Os")))
#define _O1 __attribute__((optimize("O1"))) #define _O1 __attribute__((optimize("O1")))
#define _O2 __attribute__((optimize("O2"))) #define _O2 __attribute__((optimize("O2")))
#define _O3 __attribute__((optimize("O3"))) #define _O3 __attribute__((optimize("O3")))
// Bracket code that shouldn't be interrupted // Bracket code that shouldn't be interrupted
#ifndef CRITICAL_SECTION_START #ifndef CRITICAL_SECTION_START

View file

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

View file

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

View file

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

View file

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