简体   繁体   English

如何使用此公式将GPIO引脚设置为输出(ARM组件)?

[英]How do you use this formula for setting a GPIO pin to output (ARM assembly)?

So basically guys, Im about to rip my hair out, I cannot grasp how to deal with this. 所以基本上,伙计们,我要把头发扯掉,我不知道该如何处理。 I've been given this ( gpio_addr + (4*( GPIO_NR/10))) |= (1<<(((GPIO_NR)%10)*3) 我已经得到了这个( gpio_addr + (4*( GPIO_NR/10))) |= (1<<(((GPIO_NR)%10)*3)

the gpio_address in my case is the virtual base address, which is 0x3F200000 and the first GPIO number is 17. What I dont understand is, how can you divide 17 by 10 and multiply it by 4 without loosing the remainder 7? 在我的情况下,gpio_address是虚拟基址,它是0x3F200000,而第一个GPIO数是17。我不明白的是,如何将17除以10并乘以4而不丢失其余的7?

Thanks a lot guys 非常感谢

It is very simple. 这很简单。 Your micro has two 32 bits registers for it. 您的单片机有两个32位寄存器。 Every gpio pin has its own 3 bits. 每个gpio引脚都有自己的3位。 First ten are in the first register, another 8 in the second. 前十个在第一个寄存器中,另外八个在第二个寄存器中。 When you integer divide by ten and multiply by 4 you get the address of the register. 当您将整数除以10并乘以4时,将获得寄存器的地址。 The modulo multiple 3 gives you the position in the register. 模倍数3给出您在寄存器中的位置。 Simple math. 简单的数学。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM