Fix critical section start/end
This commit is contained in:
parent
a85f60adb9
commit
35023b09ef
@ -48,8 +48,8 @@
|
|||||||
|
|
||||||
// Bracket code that shouldn't be interrupted
|
// Bracket code that shouldn't be interrupted
|
||||||
#ifndef CRITICAL_SECTION_START
|
#ifndef CRITICAL_SECTION_START
|
||||||
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli();
|
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()
|
||||||
#define CRITICAL_SECTION_END SREG = _sreg;
|
#define CRITICAL_SECTION_END SREG = _sreg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ISRS_ENABLED() TEST(SREG, SREG_I)
|
#define ISRS_ENABLED() TEST(SREG, SREG_I)
|
||||||
|
@ -68,7 +68,7 @@ static uint8_t LEDs[8] = { 0 };
|
|||||||
#define SIG_DELAY() DELAY_NS(188)
|
#define SIG_DELAY() DELAY_NS(188)
|
||||||
|
|
||||||
void Max7219_PutByte(uint8_t data) {
|
void Max7219_PutByte(uint8_t data) {
|
||||||
CRITICAL_SECTION_START
|
CRITICAL_SECTION_START;
|
||||||
for (uint8_t i = 8; i--;) {
|
for (uint8_t i = 8; i--;) {
|
||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
WRITE(MAX7219_CLK_PIN, LOW); // tick
|
WRITE(MAX7219_CLK_PIN, LOW); // tick
|
||||||
@ -79,12 +79,12 @@ void Max7219_PutByte(uint8_t data) {
|
|||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
data <<= 1;
|
data <<= 1;
|
||||||
}
|
}
|
||||||
CRITICAL_SECTION_END
|
CRITICAL_SECTION_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Max7219(const uint8_t reg, const uint8_t data) {
|
void Max7219(const uint8_t reg, const uint8_t data) {
|
||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
CRITICAL_SECTION_START
|
CRITICAL_SECTION_START;
|
||||||
WRITE(MAX7219_LOAD_PIN, LOW); // begin
|
WRITE(MAX7219_LOAD_PIN, LOW); // begin
|
||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
Max7219_PutByte(reg); // specify register
|
Max7219_PutByte(reg); // specify register
|
||||||
@ -94,7 +94,7 @@ void Max7219(const uint8_t reg, const uint8_t data) {
|
|||||||
WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data
|
WRITE(MAX7219_LOAD_PIN, LOW); // and tell the chip to load the data
|
||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
WRITE(MAX7219_LOAD_PIN, HIGH);
|
WRITE(MAX7219_LOAD_PIN, HIGH);
|
||||||
CRITICAL_SECTION_END
|
CRITICAL_SECTION_END;
|
||||||
SIG_DELAY();
|
SIG_DELAY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,14 +276,14 @@ void Max7219_init() {
|
|||||||
*/
|
*/
|
||||||
void Max7219_idle_tasks() {
|
void Max7219_idle_tasks() {
|
||||||
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
|
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
|
||||||
CRITICAL_SECTION_START
|
CRITICAL_SECTION_START;
|
||||||
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE
|
#if MAX7219_DEBUG_STEPPER_HEAD || MAX7219_DEBUG_STEPPER_QUEUE
|
||||||
const uint8_t head = planner.block_buffer_head;
|
const uint8_t head = planner.block_buffer_head;
|
||||||
#endif
|
#endif
|
||||||
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
|
#if MAX7219_DEBUG_STEPPER_TAIL || MAX7219_DEBUG_STEPPER_QUEUE
|
||||||
const uint8_t tail = planner.block_buffer_tail;
|
const uint8_t tail = planner.block_buffer_tail;
|
||||||
#endif
|
#endif
|
||||||
CRITICAL_SECTION_END
|
CRITICAL_SECTION_END;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint16_t refresh_cnt = 0; // The Max7219 circuit boards available for several dollars on eBay
|
static uint16_t refresh_cnt = 0; // The Max7219 circuit boards available for several dollars on eBay
|
||||||
|
Loading…
x
Reference in New Issue
Block a user