Go to advanced search

by ElasticBottle
Mon Jul 08, 2019 9:31 am
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Re: Help WIth GPIO C module

Looks right now ... mine aren't much different bool gpio_output (unsigned int gpio, bool on) { if (gpio < MAX_GPIO_NUM) // Check GPIO pin number valid { volatile uint32_t* p; uint32_t bit = 1 << (gpio % 32); // Create mask bit p = (on) ? &GPIO->GPSET[0] : &GPIO->GPCLR[0]; // Set pointer depending o...
by ElasticBottle
Fri Jul 05, 2019 6:14 pm
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Re: Help WIth GPIO C module

Looks right now ... mine aren't much different bool gpio_output (unsigned int gpio, bool on) { if (gpio < MAX_GPIO_NUM) // Check GPIO pin number valid { volatile uint32_t* p; uint32_t bit = 1 << (gpio % 32); // Create mask bit p = (on) ? &GPIO->GPSET[0] : &GPIO->GPCLR[0]; // Set pointer depending o...
by ElasticBottle
Wed Jul 03, 2019 7:10 am
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Re: Help WIth GPIO C module

I would assume so but your write and read have same C pointer bug did you fix them? Basically anywhere you used this "BYTEDIFF" is bugged Yes this makes more sense if (pin > GPIO_PIN_LAST) Yeap! my current code looks like this #define GPIO_CLR0 ((unsigned int *) 0x20200028) #define GPIO_SET0 ((unsi...
by ElasticBottle
Wed Jul 03, 2019 4:09 am
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Re: Help WIth GPIO C module

This is is a really weird test if (pin < GPIO_PIN_FIRST || pin > GPIO_PIN_LAST) pin is unsigned so it can't go negative and the GPIO start from zero so it seems to be nonsense. I see, so does simply changing it to: if (pin > GPIO_PIN_LAST) make the check better? as just a form of safeguard against ...
by ElasticBottle
Tue Jul 02, 2019 3:49 pm
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Re: Help WIth GPIO C module

Doesn't seem to be a "beginners" subject, and the assignment seems to be to do some bare metal programming, so moving this to bare metal. Alright, thank you so much for the re-categorization! I apologize for my lack of experience here. Could you confirm you are using bare metal, i.e. you are not ru...
by ElasticBottle
Tue Jul 02, 2019 8:46 am
Forum: Bare metal, Assembly language
Topic: Help WIth GPIO C module
Replies: 11
Views: 627

Help WIth GPIO C module

Hi guys, I am new to Raspberry Pi, and have been trying to mess around with it in C. I am running this on a bare-metal Pi, following along this page: http://cs107e.github.io/assignments/assign2/#submit Just to be clear, I am not a student there , just a regular kid trying to learn operating systems ...

Go to advanced search