资源简介
下面是一些接口文件代码:
/*
如果timeout参数不为零,则返回值为
等待信号量所花费的毫秒数。如果
信号量未在指定时间内发出信号,返回值为
SYS_ARCH_TIMEOUT。如果线程不必等待信号量
该函数返回零。 */
u32_t
sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
{
u32_t wait_tick = 0;
u32_t start_tick = 0 ;
//看看信号量是否有效
if(*sem == SYS_SEM_NULL)
return SYS_ARCH_TIMEOUT;
//首先获取开始等待信号量的时钟节拍
start_tick = xTaskGetTickCount();
//timeout != 0,需要将ms换成系统的时钟节拍
if(timeout != 0)
{
//将ms转换成时钟节拍
wait_tick = timeout / portTICK_PERIOD_MS;
if (wait_tick == 0)
wait_tick = 1;
}
else
wait_tick = portMAX_DELAY; //一直阻塞
//等待成功,计算等待的时间,否则就表示等待超时
if(xSemaphoreTake(*sem, wait_tick) == pdTRUE)
return ((xTaskGetTickCount()-start_tick)*portTICK_RATE_MS);
else
return SYS_ARCH_TIMEOUT;
}
void
sys_sem_signal(sys_sem_t *sem)
{
if(xSemaphoreGive( *sem ) != pdTRUE)
printf("[sys_arch]:sem signal fail!\n");
}
err_t
sys_mutex_new(sys_mutex_t *mutex)
{
/* 创建 sem */
*mutex = xSemaphoreCreateMutex();
if(*mutex != SYS_MRTEX_NULL)
return ERR_OK;
else
{
printf("[sys_arch]:new mutex fail!\n");
return ERR_MEM;
}
}
代码片段和文件信息
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS 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. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed *
* robust strictly quality controlled supported and cross *
* platform software that is more than just the market leader it *
* is the industry‘s de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book reference manual or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page “My application does not run what could be wrong?“. Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry CEO of Real Time Engineers
Ltd and the world‘s leading authority on the world‘s leading RTOS.
相关资源
- S32K144使用printf格式化输出
- ESP32蓝牙架构官方
- STM32F4x7_ETH_LwIP_V1.0.0
- STM32L476 FreeRTOS系统移植项目
- Design and Implementation of the lwIP TCP_IP S
- 中英两版FreeRTOS_Reference_Manual_V10.0.0.
- 周立功之LwIP的rawapi接口及编程指南,
- lwip+udp项目
- STM32F103_FREERTOS_MPU6050DMP_USART_Timer输入捕
- LwIP应用开发实战指南—基于野火+ST
- STM32F427 + LAN8710 STM32CubeMX4.25.0工程配置
- FreeRTOS 采样ADC-20200413.zip
- 基于SMT32 CubeMX的FreeRTOS工程创建及Fr
- STM32F767+FreeRTOS+LWIP移植成功(工程文件
- zcu102用lwip实现TCP传输
- STM32+FreeRTOS+W5500+MQTT
- STM32实现Web服务器
- stm32 lwip DNS DHCP ucosIII TCP Client 原创程
- STM32F207VC lwip ucosiii移植工程
- zynq++88E1111的lwip
- FreeRTOS移植工程
- LWIP在NXP公司的LPC1768上的移植
- STM32F407+LWIP+DP83848+多端口
- stm32f407 ili9341屏幕驱动 HAL库 带FreeR
- 实验1 跑马灯FreeRTOS实验.zip
- STM32_F1系列FreeRTOS工程模板
- lwip_ping.rar
- LPC1766 Lwip UDP
- DM9000+LWIP
- STM32F407FreeRTOS开发手册V1_0
评论
共有 条评论