日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

led灯点亮

發布時間:2023/12/8 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 led灯点亮 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.



手工點亮led arm匯編

start_led: mov r0,#8mov r1,#0 bl _gpio_direction_output mov r1,#0x500000 delayloop:nop sub r1,r1,#1cmp r1,#0bne delayloopmov r0,#8mov r1,#1 bl _gpio_direction_output nop mov r1,#0x500000 delayloop2:nop sub r1,r1,#1cmp r1,#0bne delayloop2/* bl _arm_blink_led */b start_led

C點亮led


int _arm_blink_led() {__asm__ __volatile__ ( "start_led:\n\t""mov r0,#8\n\t""mov r1,#0\n\t""bl _gpio_direction_output\n\t""mov r1,#0x500000\n\t" "delayloop:\n\t""nop\n\t""sub r1,r1,#1\n\t""cmp r1,#0\n\t""bne delayloop\n\t""mov r0,#8\n\t""mov r1,#1\n\t""bl _gpio_direction_output\n\t""nop\n\t""mov r1,#0x500000\n\t" "delayloop2:\n\t""nop\n\t""sub r1,r1,#1\n\t""cmp r1,#0\n\t""bne delayloop2\n\t" "b start_led\n\t");}


while(1);燈滅for (i=0,init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr,i++) {if ((*init_fnc_ptr)() != 0) {hang ();}?? ??? ?if(i==0)while(1);//燈滅if(i==1)while(1);//燈亮void start_armboot (void) {init_fnc_t **init_fnc_ptr;char *s;int i; #ifndef CFG_NO_FLASHulong size; #endif #if defined(CONFIG_VFD) || defined(CONFIG_LCD)unsigned long addr; #endif/* Pointer is writable since we allocated a register for it */gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));/* compiler optimization barrier needed for GCC >= 3.4 */__asm__ __volatile__("": : :"memory");memset ((void*)gd, 0, sizeof (gd_t));gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));memset (gd->bd, 0, sizeof (bd_t));monitor_flash_len = _bss_start - _armboot_start;gpio_direction_output(8, 0);//while(1);燈亮 }

start.s 調用c的方法

X:\c300\uboot\board\mindspeed\c300v2evm\board.c
int _gpio_direction_output(unsigned gpio, int level) { gpio_direction_output(gpio,level);return 0;} X:\c300\uboot\include\asm\arch\comcerto-300.h #ifndef __ASSEMBLY__ #include <asm/types.h> void comcerto300_init(void); int comcerto300_set_fcs(int enable, u8 cs, int base_addr, int size); int comcerto300_set_cs_type(u8 cs, int sdram_enable); int comcerto300_set_cs_region(u8 cs, u32 base, u32 size); int comcerto300_set_cse(u8 cs, int enable); void comcerto300_set_cse_highmem_to_cs1(int enable); int comcerto300_uexp_cfg_cs(u8 cs, u16 cfga, u16 cfgb, u16 cfgc); void comcerto300_pll_set_clocks(u32 arm_clock, u32 bus_clock, u32 spu_clock); void comcerto300_pll_set_arm_clock(u16 clkf, u16 clkr, u16 clkod); void comcerto300_pll_set_spu_clock(u16 clkf, u16 clkr, u16 clkod); void comcerto300_pll_set_amba_clock(u16 clkf, u16 clkr, u16 clkod); void comcerto300_ntg_8mhz_init(void); int _gpio_direction_output(unsigned gpio, int level);#endif X:\c300\uboot\cpu\arm1136\start.Smov r0,#8 mov r1,#0 bl _gpio_direction_outputffff: b ffff

int board_init(void) {/* reset on-board peripherals via GPIO line */gpio_direction_output(CFG_GPIO_OUT_PERIPHERAL_RESET, 0);while(1);udelay(100);gpio_set_value(CFG_GPIO_OUT_PERIPHERAL_RESET, 1);/* CS0 is used for SDRAM, see bsp_init() *//* CS1 and CS2 used for flash memories */nor_init();


static int __init mru_init(void) {if(misc_register(&misc)){printk(KERN_ERR "failed to register mru\n");return -1;}mru_led_enable = 0;mru_led_stat = 0;gpio_direction_output(MRU_STAT_PIN, mru_led_stat);setup_timer(&mru_timer, mru_timer_proc, (unsigned long)&mru_timer);mod_timer(&mru_timer, jiffies + msecs_to_jiffies(50));printk(KERN_INFO "register mru\n");return 0; } static void mru_timer_proc(unsigned long data) {if(mru_led_enable && ++mru_led_count >= 10){mru_led_count = 0;mru_led_stat = !mru_led_stat;gpio_set_value(MRU_STAT_PIN, mru_led_stat);}mod_timer((struct timer_list*)data, jiffies + msecs_to_jiffies(50)); } 在linux驅動中常常會碰到gpio_set_value(port_num,0/1)或gpio_direction_output (port_num,0/1) 這兩者有什么關系呢gpio_set_value(port_num,0/1) 一般只是在這個GPIO口的寄存器上寫上某個值,至于這個端口是否設置為輸出,它就管不了!而gpio_direction_output (port_num,0/1),在某個GPIO口寫上某個值之后,還會把這個端口設置為輸出模式。 因此,有人也許就會建議,把gpio_set_value這個函數直接去掉不用,是否可以,顯然是可以的。 但是為什么系統還要用呢, 我個人分析是, 系統開發人員在要結合這兩者來使用,以便提高效率。 一般某個端口設置好了輸入與輸出模式后,最好不要經常變動。 首先要調用gpio_direction_output(),以后要設置高低電平時,直接使用gpio_set_value()就可以了,這樣可以省卻再次調用設置輸出模式的操作,從而提高運行效率!
Control and status reporting for the GPIO resources is provided through nine registers. The base address for the
GPIO control registers is mapped to 0x10070000. The GPIO control registers can be accessed by adding the
associated “Offset” to the GPIO base address.

54r32GPIO中斷狀態寄存器??
54w?GPIO中斷狀態寄存器清除??
??????
58RW?中斷屏蔽寄存器00 禁止中斷
5cRW?Watchdog Timer to GPIO Select Register
(default: ‘0’)
0?
64rw?Bootstrap Pin Override Register
(default : all ‘0’). The control bits in this
register allow the programmer to
override the bootstrap pins on the device.
??
??????
??????
??????
??????
??????





0RW32GPIO 寫缺省全0?
4rw32GPIO寫使能缺省全01 輸出使能 0 輸入使能
8RW?上升沿中斷使能缺省01使能(僅當電平中斷使能沒有配置)
cRW?下降沿中斷使能01使能
10R?輸入寄存器?表示每個管腳的狀態
18RW?復用配置寄存器0?
1cR?系統狀態寄存器?0
Status of ARAMBOOT_n pin
In Normal Mode, EPROM = H and ARAMBOOT= L enable boot
from internal ARAM.
28RW?tdm復用控制寄存器"0010000_00000000?
34RW?DDR SSTL Buffer Type Register(default: “00000000_00000001”)?
50RW?電平中斷使能寄存器01 使能



總結

以上是生活随笔為你收集整理的led灯点亮的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。