Macros initial
This commit is contained in:
parent
160af0a624
commit
eb007c35d2
8 changed files with 35 additions and 32 deletions
|
@ -4,7 +4,7 @@
|
|||
#ifndef MARLIN_H
|
||||
#define MARLIN_H
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#include "macros.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -287,11 +287,6 @@ FORCE_INLINE unsigned long millis_nc() {
|
|||
void setPwmFrequency(uint8_t pin, int val);
|
||||
#endif
|
||||
|
||||
#ifndef CRITICAL_SECTION_START
|
||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
||||
#endif //CRITICAL_SECTION_START
|
||||
|
||||
extern bool fans_check_enabled;
|
||||
extern float homing_feedrate[];
|
||||
extern uint8_t axis_relative_modes;
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
#include "Configuration.h"
|
||||
#include "Marlin.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include "macros.h"
|
||||
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
#include "vector_3.h"
|
||||
#ifdef AUTO_BED_LEVELING_GRID
|
||||
|
@ -139,11 +141,6 @@
|
|||
#include "cmdqueue.h"
|
||||
#include "io_atmega2560.h"
|
||||
|
||||
// Macros for bit masks
|
||||
#define BIT(b) (1<<(b))
|
||||
#define TEST(n,b) (((n)&BIT(b))!=0)
|
||||
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
|
||||
|
||||
//Macro for print fan speed
|
||||
#define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//backlight.cpp
|
||||
|
||||
#include "backlight.h"
|
||||
#include "macros.h"
|
||||
#include <avr/eeprom.h>
|
||||
#include <Arduino.h>
|
||||
#include "eeprom.h"
|
||||
#include "Marlin.h"
|
||||
#include "pins.h"
|
||||
#include "fastio.h"
|
||||
#include "Timer.h"
|
||||
|
@ -111,10 +111,10 @@ void backlight_init()
|
|||
|
||||
#else //LCD_BL_PIN
|
||||
|
||||
void force_bl_on(__attribute__((unused)) bool section_start) {}
|
||||
void force_bl_on(_UNUSED bool section_start) {}
|
||||
void backlight_update() {}
|
||||
void backlight_init() {}
|
||||
void backlight_save() {}
|
||||
void backlight_wake(__attribute__((unused)) const uint8_t flashNo) {}
|
||||
void backlight_wake(_UNUSED const uint8_t flashNo) {}
|
||||
|
||||
#endif //LCD_BL_PIN
|
|
@ -17,10 +17,10 @@ uint8_t lang_selected = 0;
|
|||
|
||||
#if (LANG_MODE == 0) //primary language only
|
||||
|
||||
uint8_t lang_select(__attribute__((unused)) uint8_t lang) { return 0; }
|
||||
uint8_t lang_select(_UNUSED uint8_t lang) { return 0; }
|
||||
uint8_t lang_get_count() { return 1; }
|
||||
uint16_t lang_get_code(__attribute__((unused)) uint8_t lang) { return LANG_CODE_EN; }
|
||||
const char* lang_get_name_by_code(__attribute__((unused)) uint16_t code) { return _n("English"); }
|
||||
uint16_t lang_get_code(_UNUSED uint8_t lang) { return LANG_CODE_EN; }
|
||||
const char* lang_get_name_by_code(_UNUSED uint16_t code) { return _n("English"); }
|
||||
void lang_reset(void) { }
|
||||
uint8_t lang_is_selected(void) { return 1; }
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
|
||||
#include "config.h"
|
||||
#include "macros.h"
|
||||
#include <inttypes.h>
|
||||
#ifdef DEBUG_SEC_LANG
|
||||
#include <stdio.h>
|
||||
|
@ -22,9 +23,6 @@
|
|||
|
||||
#define MSG_FW_VERSION "Firmware"
|
||||
|
||||
#define STRINGIFY_(n) #n
|
||||
#define STRINGIFY(n) STRINGIFY_(n)
|
||||
|
||||
#if (LANG_MODE == 0) //primary language only
|
||||
#define PROGMEM_I2 __attribute__((section(".progmem0")))
|
||||
#define PROGMEM_I1 __attribute__((section(".progmem1")))
|
||||
|
|
18
Firmware/macros.h
Normal file
18
Firmware/macros.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef MACROS_H
|
||||
#define MACROS_H
|
||||
|
||||
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#define _UNUSED __attribute__((unused))
|
||||
|
||||
#ifndef CRITICAL_SECTION_START
|
||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
||||
#endif //CRITICAL_SECTION_START
|
||||
|
||||
// Macros to make a string from a macro
|
||||
#define STRINGIFY_(M) #M
|
||||
#define STRINGIFY(M) STRINGIFY_(M)
|
||||
|
||||
|
||||
#endif //MACROS_H
|
|
@ -10,14 +10,8 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "pins.h"
|
||||
|
||||
#ifndef CRITICAL_SECTION_START
|
||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
||||
#endif //CRITICAL_SECTION_START
|
||||
|
||||
|
||||
#include "fastio.h"
|
||||
#include "macros.h"
|
||||
|
||||
void timer4_init(void)
|
||||
{
|
||||
|
@ -79,7 +73,7 @@ ISR(TIMER4_OVF_vect)
|
|||
WRITE(BEEPER, 0);
|
||||
}
|
||||
|
||||
void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency)
|
||||
void tone4(_UNUSED uint8_t _pin, uint16_t frequency)
|
||||
{
|
||||
//this ocr and prescalarbits calculation is taken from the Arduino core and simplified for one type of timer only
|
||||
uint8_t prescalarbits = 0b001;
|
||||
|
@ -105,7 +99,7 @@ void tone4(__attribute__((unused)) uint8_t _pin, uint16_t frequency)
|
|||
CRITICAL_SECTION_END;
|
||||
}
|
||||
|
||||
void noTone4(__attribute__((unused)) uint8_t _pin)
|
||||
void noTone4(_UNUSED uint8_t _pin)
|
||||
{
|
||||
CRITICAL_SECTION_START;
|
||||
// Revert prescaler to CLK/1024
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include "rbuf.h"
|
||||
#include "macros.h"
|
||||
|
||||
#define UART2_BAUD 115200
|
||||
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5)
|
||||
|
@ -16,7 +17,7 @@ uint8_t uart2_ibuf[14] = {0, 0};
|
|||
FILE _uart2io = {0};
|
||||
|
||||
|
||||
int uart2_putchar(char c, FILE *stream __attribute__((unused)))
|
||||
int uart2_putchar(char c, _UNUSED FILE *stream)
|
||||
{
|
||||
while (!uart2_txready);
|
||||
UDR2 = c; // transmit byte
|
||||
|
@ -25,7 +26,7 @@ int uart2_putchar(char c, FILE *stream __attribute__((unused)))
|
|||
return 0;
|
||||
}
|
||||
|
||||
int uart2_getchar(FILE *stream __attribute__((unused)))
|
||||
int uart2_getchar(_UNUSED FILE *stream)
|
||||
{
|
||||
if (rbuf_empty(uart2_ibuf)) return -1;
|
||||
return rbuf_get(uart2_ibuf);
|
||||
|
|
Loading…
Reference in a new issue