首页 > 其他分享 >全志R128 SDK HAL 模块开发指南之HW Spinlock

全志R128 SDK HAL 模块开发指南之HW Spinlock

时间:2024-02-02 10:01:15浏览次数:26  
标签:HAL get int R128 全志 hwspinlock num hal include

模块介绍

hwspinlock 提供一种硬件同步机制,lock 操作可以防止多处理器同时处理共享数据。保证数据的一致性。

源码结构

├── hal_hwspinlock.c
├── hwspinlock.h
├── Kconfig
├── Makefile
├── platform
│   ├── hwspinlock-sun20iw2.h 
└── platform-hwspinlock.h

模块配置

配置路径如下:

There is no help available for this option. Symbol: DRIVERS_HWSPINLOCK [=y]
Type : boolean
Prompt: enable hwspinlock driver
Location:
    -> Drivers options
        -> Supported drivers
            -> HW SPINLOCK Devices

模块接口说明

头文件:

#include <hal_hwspinlock.h>

获取锁

函数原型

int hal_hwspinlock_get(int num)

参数:

  • num0~31,hwspinlock 锁的序号

返回值:

  • HWSPINLOCK_OK:上锁完成
  • HWSPINLOCK_EXCEED_MAX:锁已达最大值,获取失败
  • HWSPINLOCK_ERR:上锁失败

解锁

函数原型

int hal_hwspinlock_put(int num)

参数:

  • num0~31,hwspinlock 锁的序号

返回值:

  • HWSPINLOCK_OK:上锁完成
  • HWSPINLOCK_EXCEED_MAX:锁已达最大值,获取失败

检查锁是否在使用中

函数原型

int hal_hwspinlock_check_taken(int num)

参数:

  • num0~31,hwspinlock 锁的序号

返回值

  • 1:使用中
  • 0:未被使用

模块使用范例

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <hal_log.h>
#include <hal_cmd.h>
#include <hal_hwspinlock.h>

static int cmd_test_hwspinlock_get(int argc, char **argv)
{
    hal_hwspinlock_get(0);
    return 0;
}

static int cmd_test_hwspinlock_put(int argc, char **argv)
{
    hal_hwspinlock_put(0);
    return 0;
}

FINSH_FUNCTION_EXPORT_CMD(cmd_test_hwspinlock_get, hal_hwspinlock_get, test_hwspinlock)
FINSH_FUNCTION_EXPORT_CMD(cmd_test_hwspinlock_put, hal_hwspinlock_put, test_hwspinlock)

在 FreeRTOS 控制台输入 hal_hwspinlock_get 命令会上锁,输入 hal_hwspinlock_put 命令会解锁。

标签:HAL,get,int,R128,全志,hwspinlock,num,hal,include
From: https://blog.51cto.com/u_15380233/9542298

相关文章

  • datawhale-leetcode打卡:038~050题
    两数相加(leetcode002)#Definitionforsingly-linkedlist.#classListNode:#def__init__(self,val=0,next=None):#self.val=val#self.next=nextclassSolution:defaddTwoNumbers(self,l1:Optional[ListNode],l2:Optional[List......
  • 计算机服务器中了halo勒索病毒怎么办,halo勒索病毒解密处理流程
    计算机技术的发展与应用为企业的生产生活提供了坚实基础,但同时也为网络安全威胁制造了有利条件。近期,网络上的勒索病毒非常嚣张,给企业的计算机服务器带来严重威胁。近日,云天数据恢复中心接到山东某制造公司的求助,企业的计算机服务器被halo勒索病毒攻击,导致系统所有数据被加密无法使......
  • 修复“Monty Hall”游戏模拟的错误输出
    最近公司在做模拟器开发,因为开发技术员都是新手,经常遇到很多逻辑上得错误。游戏ROM文件没有损坏或错误。有时候下载的ROM文件可能出现问题,导致模拟器无法正确加载。有些模拟器提供调试选项,可以帮助你识别和解决问题。但是大部分得问题还得要我们自己解决。例如下列得问题。问题......
  • jeecg-boot 同步数据库失败,Unable to perform unmarshalling at line number 5 and co
    同步数据库失败,Unabletoperformunmarshallingatlinenumber5andcolumn6.Message:cvc-complex-type.2.4.a:Invalidcontentwasfoundstartingwithelement'{"http://www.hibernate.org/xsd/orm/hbm":property}'.Oneof'{"http://www......
  • 【产品兼容认证】WhaleStudio 成功兼容TiDB数据库软件
    平凯星辰和白鲸开源宣布成功完成产品兼容认证北京,2023年12月27日-平凯星辰(北京)科技有限公司(以下简称平凯星辰)旗下的TiDB产品与白鲸开源的WhaleStudio已成功完成产品兼容性认证。这一重要合作旨在为全球客户提供更大的价值。关于WhaleStudioWhaleStudio是一款由Apache......
  • 【产品兼容认证】WhaleStudio 成功兼容TiDB数据库软件
    平凯星辰和白鲸开源宣布成功完成产品兼容认证北京,2023年12月27日-平凯星辰(北京)科技有限公司(以下简称平凯星辰)旗下的TiDB产品与白鲸开源的WhaleStudio已成功完成产品兼容性认证。这一重要合作旨在为全球客户提供更大的价值。关于WhaleStudioWhaleStudio是一款由Apache......
  • HALCON 杂记
    1.emphasize—Enhancecontrastoftheimage.  增强图像对比度emphasize(Image:ImageEmphasize:MaskWidth,MaskHeight,Factor:)  read_image(Image,'mreut')dev_display(Image)*手动划区域draw_region(Region,WindowHandle)reduce_domain(Image,Regio......
  • halcon 双目相机标定
    *Applicationprogramtodemonstratethecalibrationof*abinocularstereosystemusingtheoperators*find_caltab,find_marks_and_pose,andbinocular_calibration.**Asanalternative,acalibrationdatamodelcouldbeused.*Pleaserefertotheex......
  • datawhale-leetcode打卡:001-012题
    这次这十二个题目属于是极限肝出来的,有两个参考了一下题解,还是很有意思。我会按照我个人的感觉去写这个东西。螺旋矩阵(leetcode054)这个题目比较恶心的就是跑圈的过程怎么描述。首先,顺时针一圈下来是先从左到右,顶到最右边i<m,好再往下,顶到最下边i<n,好现在i--往回排,最后j--走完一......
  • 全志R128 Devkit开发板原理图模块介绍及使用说明
    针对R128模组,百问科技推出了R128DevKit开发板作为快速开发评估工具。板载R128-S2-N16R16模组板载2.4GRF陶瓷天线板载USBTypeCOTG板载UART转USB芯片板载RESET,FEL下载按键板载4颗WS2812RGBLED板载PMU,支持对外供电3.3V1A提供GPIO37个,引出3路MIC,2路......