I'm gone through Lesson 1-7 in assembly (and it all works woo!), so I figured I'd try to
do the same now, but in C. So far I've successfully taken command of the LED, so I've got something working at least.
My problems starts with Lesson 6 Screen 01, I have with the usage of the LED managed to determine that
my mailboxRead() function gets stuck, however I can't for the life of me figure out why.
I am a little bit confused as to how the whole "storing the address of a c variable at the correct address (in the mailbox) works.
The code is pretty long and messy, so I'll try to just ask the things (I think) I'm struggling with.
To write to the mailbox, I do this:
Code: Select all
unsigned int info[256] __attribute__((aligned (16)));
info[0] = 1024;
info[1] = 768;
info[2] = 1024;
info[3] = 768;
// ... omitted the rest of the struct for brevity ....
unsigned int *mailboxStatus= (unsigned int *)(0x2000b898);
while(*mailboxStatus & MAILBOX_FULL){
}
unsigned int* mailboxWrite = (unsigned int *)0x2000b8a0;
*mailboxWrite = ((unsigned int)info + 0x40000000) | 1; // Write to channel 1and as far as I can tell I'm using the same logic as well.
Might be wondering what my mailboxRead function looks like as I mentioned it gets stuck there:
Code: Select all
unsigned int mailbox_Read(char channel){
unsigned int data = 0;
unsigned int* mailboxStatus = (unsigned int *)(0x2000b898);
while(1){
while (*mailboxStatus & 0x40000000){
}
data = *(unsigned int*) 0x2000B880;
if((data & 0xF) == channel)
{
break;
}
}
}Any pointers/ideas are greatly appreciated, thank you.
(Sorry for a long first post by the way, I tried to keep it short!)
// Simon