百行代码解读阿里 AloT 芯片平台无剑 100!
2019-10-28 16:11
1666 查看
VIC
内存
DMA控制器*1
定时器*8
GPIO (×1)
always@(*)/*Verilog的逻辑一般由alway关键字定义,其中()内部的变量变化时执行下面代码,如果是*则代表所有input发生变化都会解发语句执行*/
begin
if((psel == 1'b1) && (penable == 1'b1) && (pwrite == 1'b1)) begin/*verilog中的如1'b1,'前面的1代表一位长度,b代表二进制编码,'后面的1代表具体数值,本例中是说psel即选中标志,与penable即可用标志和pwirte即可写标志均为1是进入以下语句*/
if(paddr[TIMER_ADDR_LHS:2] == TIMER1LC_OFFSET)//如果是timer1的LOADCOUNT的OFFSET
timer1loadcount_wen = 1'b1;//将timer1的loadcount的event位配置为1
else
timer1loadcount_wen = 1'b0; //将timer1的loadcount的event位配置为0
end
else
timer1loadcount_wen = 1'b0; //将timer1的loadcount的event位配置为0
end
|
|||
|
|||
timer_handle_t csi_timer_initialize(int32_t idx, timer_event_cb_t cb_event)//idx代表计时器的id,cb_event是回调事件
{
if (idx < 0 || idx >= CONFIG_TIMER_NUM) {
return NULL;
}
uint32_t base = 0u;
uint32_t irq = 0u;
void *handler;
int32_t real_idx = target_get_timer(idx, &base, &irq, &handler);
if (real_idx != idx) {//合法怕校验
return NULL;
}
dw_timer_priv_t *timer_priv = &timer_instance[idx];//设计timer的优先级
timer_priv->base = base;
timer_priv->irq = irq;//设置硬中断请求优先级
timer_priv->idx = idx;
dw_timer_reg_t *addr = (dw_timer_reg_t *)(timer_priv->base);
timer_priv->timeout = DW_TIMER_INIT_DEFAULT_VALUE;
#ifdef CONFIG_LPM
csi_timer_power_control(timer_priv, DRV_POWER_FULL);
#endif
timer_deactive_control(addr);//启用前先禁用
timer_priv->cb_event = cb_event;
if (cb_event != NULL) {
drv_irq_register(timer_priv->irq, handler);//注册硬件优先级
drv_irq_enable(timer_priv->irq);//启用
}
return (timer_handle_t)timer_priv;
}
int clock_timer_init(void)
{
if (CLOCK_GETTIME_USE_TIMER_ID > CONFIG_TIMER_NUM) {
return EPERM;
}
uint32_t timer_loadtimer;
timer_handle = csi_timer_initialize(CLOCK_GETTIME_USE_TIMER_ID, timer_cb_fun);
if (timer_handle == NULL) {
return -1;
}
APB_FREQ = drv_get_timer_freq(CLOCK_GETTIME_USE_TIMER_ID);
timer_loadtimer = 10 * MILLION; /*10Mus=10s */
TIMER_LOADCOUNT = timer_loadtimer * (APB_FREQ / MILLION);
int ret = csi_timer_config(timer_handle, TIMER_MODE_RELOAD);
if (ret != 0) {
return -1;
}
ret = csi_timer_set_timeout(timer_handle, timer_loadtimer);
if (ret != 0) {
return -1;
}
unsigned int cv1, cv2;
csi_timer_get_current_value(timer_handle, &cv1);
csi_timer_get_current_value(timer_handle, &cv2);
if (cv2 > cv1) {
timer_count_rise = 1;
}
return 0;
}
热 文 推 荐
☞腾讯首次攻破屏下指纹识别技术;苹果新Mac Pro最贵将卖到4.2万;Haxe 4.0发布 | 极客头条
点击阅读原文参与问卷,好礼送不停!
相关文章推荐
- 独家解读!阿里首次披露自研飞天大数据平台技术架构
- 解读阿里官方代码规范
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 8月30日科技资讯|华为宣布方舟编译器将开源;阿里发布一站式芯片设计平台;Ant Design 3.22.2 发布
- 解读阿里官方代码规范
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 使用阿里大于平台发送短信验证码java代码实现
- 展讯智能机平台代码i2c设备驱动解读(上)
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 阿里如何实现秒级百万TPS?搜索离线大数据平台架构解读
- 展讯智能机平台代码 i2c设备驱动解读(下)
- 200 行代码解读国产数据库阿里 OceanBase 的速度源头!| CSDN 博文精选
- 200 行代码解读国产数据库阿里 OceanBase 的速度源头!| CSDN 博文精选
- prototype1.3.1源代码解读
- 双11阿里新供应链架构解读
- OpenDaylight(氢版本)数据通信代码解读
- 全球首个公有云GIS平台ArcGIS Online全面解读(二)
- 快速搭建sonar代码质量管理平台