Commit 391c11cf0eddebfacde080ac466f66fc66c0a792
1 parent
00a95789
Added handling of PSR (simpified)
Showing
2 changed files
with
12 additions
and
11 deletions
hw/at91_pio.c
... | ... | @@ -194,10 +194,12 @@ static void at91_pio_mem_write(void *opaque, target_phys_addr_t offset, |
194 | 194 | uint32_t prev; |
195 | 195 | switch (offset) { |
196 | 196 | case PIO_PER: |
197 | - s->psr |= value; | |
197 | + s->psr |= value; //we should also detect LED state change in some cases | |
198 | + //printf("enabling, psr=0x%08x\n", s->psr); | |
198 | 199 | break; |
199 | 200 | case PIO_PDR: |
200 | 201 | s->psr &= ~value; |
202 | + //printf("disabling, psr=0x%08x\n", s->psr); | |
201 | 203 | break; |
202 | 204 | case PIO_OER: |
203 | 205 | s->osr |= value; |
... | ... | @@ -215,10 +217,10 @@ static void at91_pio_mem_write(void *opaque, target_phys_addr_t offset, |
215 | 217 | prev = s->odsr; |
216 | 218 | s->odsr |= value; |
217 | 219 | for (i = 0; i < PIO_PINS; i++) |
218 | - if (value & (1 << i) & s->osr) | |
220 | + if (value & (1 << i) & s->osr & s->psr) | |
219 | 221 | { |
220 | 222 | qemu_set_irq(s->out[i], 1); |
221 | - if(prev != s->odsr) | |
223 | + if((prev & (1 << i)) != (s->odsr & (1 << i))) | |
222 | 224 | { |
223 | 225 | DPRINTF("Port %c%d set\n",'A' + s->portid, i); |
224 | 226 | if ((s->portid == 1) && (i == 8)) |
... | ... | @@ -232,10 +234,10 @@ static void at91_pio_mem_write(void *opaque, target_phys_addr_t offset, |
232 | 234 | prev = s->odsr; |
233 | 235 | s->odsr &= ~value; |
234 | 236 | for (i = 0; i < PIO_PINS; i++) |
235 | - if (value & (1 << i) & s->osr) | |
237 | + if (value & (1 << i) & s->osr & s->psr) | |
236 | 238 | { |
237 | 239 | qemu_set_irq(s->out[i], 0); |
238 | - if(prev != s->odsr) | |
240 | + if((prev & (1 << i)) != (s->odsr & (1 << i))) | |
239 | 241 | { |
240 | 242 | DPRINTF("Port %c%d reset\n",'A' + s->portid, i); |
241 | 243 | if ((s->portid == 1) && (i == 8)) | ... | ... |
virtual_lab/main.c
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | #include <stdbool.h> |
3 | 3 | |
4 | 4 | #define PA_PER (*((volatile uint32_t*)0xFFFFF200)) |
5 | +#define PA_PDR (*((volatile uint32_t*)0xFFFFF204)) | |
5 | 6 | #define PA_OER (*((volatile uint32_t*)0xFFFFF210)) |
6 | 7 | #define PA_SODR (*((volatile uint32_t*)0xFFFFF230)) |
7 | 8 | #define PA_CODR (*((volatile uint32_t*)0xFFFFF234)) |
... | ... | @@ -9,6 +10,7 @@ |
9 | 10 | |
10 | 11 | |
11 | 12 | #define PB_PER (*((volatile uint32_t*)0xFFFFF400)) |
13 | +#define PB_PDR (*((volatile uint32_t*)0xFFFFF404)) | |
12 | 14 | #define PB_OER (*((volatile uint32_t*)0xFFFFF410)) |
13 | 15 | #define PB_SODR (*((volatile uint32_t*)0xFFFFF430)) |
14 | 16 | #define PB_CODR (*((volatile uint32_t*)0xFFFFF434)) |
... | ... | @@ -46,13 +48,10 @@ void delay(void) |
46 | 48 | |
47 | 49 | int main(void) |
48 | 50 | { |
49 | - PMC_PCER = 1 << PER_ID_PBIOC_TO_PIOE; | |
50 | - | |
51 | - PA_PER = 0x23; //PIO enable register | |
52 | - PA_OER = 0x54; //PIO controller output enable register | |
53 | - | |
54 | - | |
51 | + PMC_PCER = 1 << PER_ID_PBIOC_TO_PIOE; | |
55 | 52 | PB_PER = DS1; //PIO enable register |
53 | +// PB_PDR = 0xffffffff; //PIO disable register | |
54 | + | |
56 | 55 | PB_OER = DS1; //PIO controller output enable register |
57 | 56 | PC_PER = DS2 | BT1 | BT2; //PIO enable register |
58 | 57 | PC_OER = DS2; //PIO controller output enable register | ... | ... |