📄 entry.c
字号:
#include "includes.h"
#include "atj213x.h"
#include "actions_reg_213x.h"
#include "radio_player.h"
#include "irq_timer.h" //soft timer.
#include "device.h" //setupCorePll, changeCorePll, chipCheck
#include "regdef.h"
#define StoreStation 0xB404F000
typedef struct
{
INT32U chNum;
INT32U chs[15];
}StationStruct;
void delay(void);
extern unsigned int saved_gpio1;
extern unsigned int i2c_gpio;
static INT32U spSaver;
#define newSp 0xB4050000
void SearchStations(void)
{
// 关所有中断
// __asm__ ("di");
// read_modify_write(0xb0018014, 0x24);
// read_modify_write(0xb0018014, 0x30);
// while(1);
__asm__ ("la $8, spSaver");
__asm__ ("sw $29, 0($8)");
__asm__ ("li $29, 0xB4050000");
INT32U temp; // 中间临时变量
INT32U CMU_BUS_CLK; // 多路开关控制寄存器
INT32U CMU_CORE_PLL; // 系统锁相环控制寄存器
INT32U SDR_CMD_REG; // SDRAM 命令寄存器
// 保留了原始值,这样在后续中,就可任意设值了
CMU_BUS_CLK = act_readl(CMU_BUSCLK);
CMU_CORE_PLL = act_readl(CMU_COREPLL);
SDR_CMD_REG = act_readl(SDR_CMD);
INT32U freq;
StationStruct* p;
p = (StationStruct*) StoreStation;
p->chNum = 0;
// 关所有中断
__asm__ ("di");
// 获得I2C总线
saved_gpio1 = act_readl(GPIO_MFCTL1);
i2c_gpio = saved_gpio1 & 0xffffffcf; //multi-function: I2C1 SCL and SDA
i2c_gpio = i2c_gpio | 0x80000000; //multi-function enable
act_writel(i2c_gpio, GPIO_MFCTL1);
// SDRAM自刷新
act_writel(0x10, SDR_CMD);
act_writel(0x00, SDR_EN);
// 切换系统时钟到低频晶振
temp = CMU_BUS_CLK & (~0x00c0) | (0x1 << 31) | (0x1 << 27);
act_writel(temp, CMU_BUSCLK);
delay();
// 关闭高频晶振
temp = CMU_CORE_PLL & (~0x00c0);
act_writel(temp, CMU_COREPLL);
for(freq = 95900; freq <= 96100; freq += 100)
{
if(!(is_freq_valid_station(freq))) // 有台
{
p->chs[p->chNum++] = freq;
}
}
// 打开高频晶振
temp = CMU_CORE_PLL | 0x00c0;
act_writel(temp, CMU_COREPLL);
delay();
// 切换系统时钟到高频晶振
temp = CMU_BUS_CLK & (~0x00c0);
temp |= 0x0080;
act_writel(temp, CMU_BUSCLK);
delay();
// 退出SDRAM自刷新
act_writel(0x01, SDR_EN);
delay();
act_writel(0x12, SDR_CMD);
delay();
// 释放I2C总线
act_writel(saved_gpio1, GPIO_MFCTL1);
__asm__(" la $8, spSaver; \
lw $29, 0($8); \
");
// 开所有中断
__asm__ ("ei");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -