📄 hw_generic.c
字号:
/* * Copyright (C) 2006 Pawel Kolodziejski * * Some defines are from linux 2.6 kernel sources * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include "types.h"#include "setup.h"#include "pxa-regs.h"#include "gpio.h"#define KEY_NONE 0#define KEY_POWER 1#define KEY_HOME 4#define KEY_CALENDAR 8#define KEY_TASKS 16#define KEY_CONTACTS 32unsigned long getKeys(void) { unsigned long gpio_keys, keys; keys = KEY_NONE; gpio_keys = *(unsigned long *)0x40E00000; if ((gpio_keys & 0x1) != 0x1) keys |= KEY_POWER; if ((gpio_keys & 0x4) != 0x4) keys |= KEY_HOME; if ((gpio_keys & 0x8) != 0x8) keys |= KEY_TASKS; if ((gpio_keys & 0x10) != 0x10) keys |= KEY_CALENDAR; if ((gpio_keys & 0x20) != 0x20) keys |= KEY_CONTACTS; return keys;}unsigned long waitForKey(void) { for (;;) { unsigned long keys = getKeys(); if (keys != KEY_NONE) return keys; mdelay(1); }}int blue_led_on(void) { GPSR0 = 0x00020000;}int blue_led_off(void) { GPCR0 = 0x00020000;}int _delay(u32 delay) { u64 cur_time = OSCR; u32 max_time; if ((cur_time + delay) > 0xffffffff) { OSCR = 0; max_time = delay; } else { max_time = cur_time + delay; } while (OSCR < max_time) {};}int mdelay(u32 delay) { _delay((delay * 36864) / 10);}u32 gpo_local;int gpo_set(unsigned long bits) { gpo_local |= bits; *(volatile u32 *)0x10000000 = gpo_local;}int gpo_clear(unsigned long bits) { gpo_local &= ~bits; *(volatile u32 *)0x10000000 = gpo_local;}int gpo_init(void) { gpo_local = 0x62878200L; *(volatile u32 *)0x10000000 = gpo_local;}int init_pm(void) { PGSR0 = 0x00080000; PGSR1 = 0x03ff0300; PGSR2 = 0x00010400; PWER = PWER_GPIO0; PFER = PWER_GPIO0; PRER = 0; PEDR = 0; PCFR = PCFR_OPDE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -