Skip to content

Commit

Permalink
Use defines for 8018X REQST & MASK register bits
Browse files Browse the repository at this point in the history
  • Loading branch information
mfld-fr committed Dec 4, 2023
1 parent f4fac22 commit 65f8297
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions int-8018x.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
#define INT_REG_I2CON 13
#define INT_REG_I3CON 14

// REQST and MASK register bits
#define BIT_TMR 0
// Bit 1 is reserved on all models
// Bits 2 & 3 are for DMA in XL variant
// Bits 2 & 3 are for serial and INT4 for EB variant
#define BIT_SER 2
#define BIT_INT4 3
#define BIT_INT0 4
#define BIT_INT1 5
#define BIT_INT2 6
#define BIT_INT3 7

int _int_line_max = INT_LINE_MAX;
int _int_prio_max = INT_PRIO_MAX;

Expand Down Expand Up @@ -60,11 +72,11 @@ int int_io_read (word_t p, word_t * w)
{
word_t out = 0;
for (size_t i = 0; i < 8; i++) {
if (i == 0) {
if (i == BIT_TMR) {
if (_int_req[INT_LINE_TIMER0] || _int_req[INT_LINE_TIMER1] || _int_req[INT_LINE_TIMER2]) {
out |= 1 << i;
}
} else if (i == 2) {
} else if (i == BIT_SER) {
if (_int_req[INT_LINE_SERIAL_RX] || _int_req[INT_LINE_SERIAL_TX]) {
out |= 1 << i;
}
Expand All @@ -78,11 +90,11 @@ int int_io_read (word_t p, word_t * w)
{
word_t out = 0;
for (size_t i = 0; i < 8; i++) {
if (i == 0) {
if (i == BIT_TMR) {
if (_int_mask[INT_LINE_TIMER0]) {
out |= 1 << i;
}
} else if (i == 2) {
} else if (i == BIT_SER) {
if (_int_mask[INT_LINE_SERIAL_RX]) {
out |= 1 << i;
}
Expand Down Expand Up @@ -155,12 +167,12 @@ int int_io_write (word_t p, word_t w)
for (int i = 0; i < 8; i++) {
int mask = (w & 0x01) ? 1 : 0;

if (i == 0) {
if (i == BIT_TMR) {
_int_mask[INT_LINE_TIMER0] = mask;
_int_mask[INT_LINE_TIMER1] = mask;
_int_mask[INT_LINE_TIMER2] = mask;
}
else if (i == 2) {
else if (i == BIT_SER) {
_int_mask[INT_LINE_SERIAL_RX] = mask;
_int_mask[INT_LINE_SERIAL_TX] = mask;
}
Expand Down

0 comments on commit 65f8297

Please sign in to comment.