mirror of
https://github.com/xushoucai/RTL8710_SDK_GCC_VERSION.git
synced 2024-11-27 08:40:33 +00:00
1d3357d3b0
including cross compilation of the installation, compile, link, run, debug, and so on. SDK implementation of the function: 1, WiFi connection settings (including AP mode and STA mode). 2, peripheral resource control (including GPIO, SPI, UART, IIC, etc.). 3, the user uses the sample method.
64 lines
1.8 KiB
C
64 lines
1.8 KiB
C
/*
|
|
* Routines to access hardware
|
|
*
|
|
* Copyright (c) 2013 Realtek Semiconductor Corp.
|
|
*
|
|
* This module is a confidential and proprietary property of RealTek and
|
|
* possession or use of this module requires written permission of RealTek.
|
|
*/
|
|
|
|
#include "osdep_service.h"
|
|
#include "device_lock.h"
|
|
|
|
//------------------------------------------------------
|
|
#define DEVICE_MUTEX_IS_INIT(device) (mutex_init & (1<<device))
|
|
#define DEVICE_MUTEX_SET_INIT(device) (mutex_init |= (1<<device))
|
|
#define DEVICE_MUTEX_CLR_INIT(device) (mutex_init &= (~(1<<device)))
|
|
|
|
static u32 mutex_init = 0;
|
|
static _mutex device_mutex[RT_DEV_LOCK_MAX];
|
|
|
|
//======================================================
|
|
static void device_mutex_init(RT_DEV_LOCK_E device)
|
|
{
|
|
if(!DEVICE_MUTEX_IS_INIT(device)){
|
|
_lock lock;
|
|
_irqL irqL;
|
|
rtw_enter_critical(&lock, &irqL);
|
|
if(!DEVICE_MUTEX_IS_INIT(device)){
|
|
rtw_mutex_init(&device_mutex[device]);
|
|
DEVICE_MUTEX_SET_INIT(device);
|
|
}
|
|
rtw_exit_critical(&lock, &irqL);
|
|
}
|
|
}
|
|
|
|
//======================================================
|
|
static void device_mutex_free(RT_DEV_LOCK_E device)
|
|
{
|
|
if(DEVICE_MUTEX_IS_INIT(device)){
|
|
_lock lock;
|
|
_irqL irqL;
|
|
rtw_enter_critical(&lock, &irqL);
|
|
if(!DEVICE_MUTEX_IS_INIT(device)){
|
|
rtw_mutex_free(&device_mutex[device]);
|
|
DEVICE_MUTEX_CLR_INIT(device);
|
|
}
|
|
rtw_exit_critical(&lock, &irqL);
|
|
}
|
|
}
|
|
|
|
//======================================================
|
|
void device_mutex_lock(RT_DEV_LOCK_E device)
|
|
{
|
|
device_mutex_init(device);
|
|
while(rtw_mutex_get_timeout(&device_mutex[device], 10000)<0)
|
|
printf("device lock timeout: %d\n", device);
|
|
}
|
|
|
|
//======================================================
|
|
void device_mutex_unlock(RT_DEV_LOCK_E device)
|
|
{
|
|
device_mutex_init(device);
|
|
rtw_mutex_put(&device_mutex[device]);
|
|
}
|