开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
开源项目 > 工业软件 > 智能硬件 &&
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
9 Star 166 Fork 18

GVP RTduino/RTduino

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
master
分支 (2)
标签 (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (3)
master
spi-fix
v1.0.0
v0.1.1
v0.1.0
RTduino
/
core
/
Arduino.h
RTduino
/
core
/
Arduino.h
Arduino.h 29.15 KB
一键复制 编辑 原始数据 按行查看 历史
满鉴霆 提交于 2025年01月19日 02:44 +08:00 . [core][LLT] add Serial LLT test cases
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888
/**
* @file Arduino.h
* @brief Arduino Core Header File.
* @author Meco Man
* @date 2021年12月10日
* @version 1.0
*
* @details
* This file is part of RTduino project.
*
* The `Arduino.h` file is a core header file that plays a pivotal role in Arduino development.
* It provides fundamental definitions, constants, and functions essential for writing
* Arduino sketches and working with the Arduino framework.
*
* This file includes declarations for common data types, standard constants, and core
* functions used in Arduino programming. It serves as the entry point for Arduino sketches,
* ensuring that the necessary core features are available for use.
*
* @copyright
* - Copyright (c) 2005-2013, Arduino Team. All right reserved.
* - Copyright (c) 2021-2023, RTduino Development Team. All rights reserved.
*
* @note
* SPDX-License-Identifier: LGPL-v2.1
*
* @see
* - GitHub: https://github.com/RTduino/RTduino
* - Gitee: https://gitee.com/rtduino/RTduino
*/
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __ARDUINO_CORE_H__
#define __ARDUINO_CORE_H__
#include <rtdevice.h>
#include <rthw.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include "Binary.h"
#include "avr/io.h"
#include "avr/stdlib.h"
#include "avr/pgmspace.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef RTDUINO_TINY_MODE
#include "pins_arduino.h"
#endif /* RTDUINO_TINY_MODE */
#ifdef RT_VER_NUM
#if RT_VER_NUM < 0x50000
#ifndef rt_align
#define rt_align(x) ALIGN(x)
#endif /* rt_align */
#ifndef rt_weak
#define rt_weak RT_WEAK
#endif /* rt_weak */
#elif RT_VER_NUM < 0x40101
#error "The minimum version requirement of RT-Thread is 4.1.1"
#endif /* RT_VER_NUM < 0x50000 */
#else
#error "Please use RT-Thread Standard Version with software packages management system!"
#endif /* RT_VER_NUM */
/**
* @defgroup Bits and Bytes
* @brief Bit and byte data type definitions.
*/
/**
* @defgroup Digital I/O
* @brief Digital input and output pins.
*/
/**
* @defgroup Maths
* @brief Mathematical definitions and functions.
*/
/**
* @defgroup Time
* @brief Time-related functions and definitions.
*/
/**
* @defgroup Advanced I/O
* @brief Advanced input and output functions.
*/
/**
* @defgroup Analog I/O
* @brief Analog input and output functions.
*/
/**
* @defgroup Interrupts
* @brief Interrupt-related functions and definitions.
*/
/**
* @defgroup External Interrupts
* @brief External interrupt functions and definitions.
*/
/**
* @defgroup Random Numbers
* @brief Random number generation functions.
*/
/**
* @defgroup System
* @brief System-related functions and initialization.
*/
/**
* @struct pin_map_t
* @brief RTduino pin map structure.
* @details
* This structure defines the mapping between Arduino pins and RT-Thread pins.
*/
typedef struct
{
uint8_t arduino_pin; /**< Arduino pin number */
rt_base_t rt_pin; /**< RT-Thread pin number */
const char* device_name; /**< Device name */
rt_int8_t channel; /**< Channel number */
} pin_map_t;
/**
* @typedef word
* @brief Represents a 16-bit unsigned integer.
* @ingroup Bits and Bytes
*/
typedef unsigned int word;
/**
* @typedef boolean
* @brief Represents a boolean value (true or false).
* @ingroup Bits and Bytes
*/
typedef bool boolean;
/**
* @typedef byte
* @brief Represents an 8-bit unsigned integer.
* @ingroup Bits and Bytes
*/
typedef uint8_t byte;
/**
* @brief Represents a low state (0V).
* @ingroup External Interrupts
*/
#define LOW 0x0
/**
* @brief Represents a high state (usually 3.3V or 5V).
* @ingroup External Interrupts
*/
#define HIGH 0x1
/**
* @brief Represents a change in state.
* @ingroup External Interrupts
*/
#define CHANGE 0x2
/**
* @brief Represents a transition from high to low.
* @ingroup External Interrupts
*/
#define FALLING 0x3
/**
* @brief Represents a transition from low to high.
* @ingroup External Interrupts
*/
#define RISING 0x4
/**
* @brief Configures the pin as an input.
* @ingroup Digital I/O
*/
#define INPUT 0x0
/**
* @brief Configures the pin as an output.
* @ingroup Digital I/O
*/
#define OUTPUT 0x1
/**
* @brief Configures the pin as an input with an internal pull-up resistor.
* @ingroup Digital I/O
*/
#define INPUT_PULLUP 0x2
/**
* @brief Configures the pin as a floating input (same as INPUT).
* @note RTduino extension.
* @ingroup Digital I/O
*/
#define INPUT_FLOATING INPUT
/**
* @brief Configures the pin as an input with an internal pull-down resistor.
* @note RTduino extension.
* @ingroup Digital I/O
*/
#define INPUT_PULLDOWN 0x3
/**
* @brief Configures the pin as an open-drain output.
* @note RTduino extension.
* @ingroup Digital I/O
*/
#define OUTPUT_OPEN_DRAIN 0x4
/**
* @brief A constant representing the ratio of a circle's circumference to its diameter.
* @ingroup Maths
*/
#define PI 3.1415926535897932384626433832795
/**
* @brief A constant representing half of the mathematical constant π (pi) in programming and mathematics.
* @ingroup Maths
*/
#define HALF_PI 1.5707963267948966192313216916398
/**
* @brief A constant representing two times the mathematical constant π (pi) in programming and mathematics.
* @ingroup Maths
*/
#define TWO_PI 6.283185307179586476925286766559
/**
* @brief A constant for converting degrees to radians in mathematics and programming applications.
* @ingroup Maths
*/
#define DEG_TO_RAD 0.017453292519943295769236907684886
/**
* @brief A constant for converting radians to degrees in mathematical and programming contexts.
* @ingroup Maths
*/
#define RAD_TO_DEG 57.295779513082320876798154814105
/**
* @brief Euler's constant.
* @ingroup Maths
*/
#define EULER 2.718281828459045235360287471352
#define SERIAL 0x0
#define DISPLAY 0x1
/**
* @brief Least Significant Bit first.
* @ingroup Bits and Bytes
*/
#define LSBFIRST 0
/**
* @brief Most Significant Bit first.
* @ingroup Bits and Bytes
*/
#define MSBFIRST 1
/*
to prevent the error of redefinition of min and max:
#define RTDUINO_NO_MIN
#define RTDUINO_NO_MAX
#include <RTduino.h>
*/
#ifndef RTDUINO_NO_MIN
/**
* @ingroup Maths
* @brief Returns the smaller of two values.
* @param a First value.
* @param b Second value.
* @return The smaller of the two values.
*/
#define min(a, b) ((a)<(b)?(a):(b))
#endif /* RTDUINO_NO_MIN */
#ifndef RTDUINO_NO_MAX
/**
* @ingroup Maths
* @brief Returns the larger of two values.
* @param a First value.
* @param b Second value.
* @return The larger of the two values.
*/
#define max(a, b) ((a)>(b)?(a):(b))
#endif /* RTDUINO_NO_MAX */
/**
* @ingroup Maths
* @brief Constrains a value to be within a specified range.
* @param amt The value to constrain.
* @param low The lower end of the range.
* @param high The upper end of the range.
* @return The constrained value.
*/
#define constrain(amt, low, high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
/**
* @ingroup Maths
* @brief Converts degrees to radians.
* @param deg The angle in degrees.
* @return The angle in radians.
*/
#define radians(deg) ((deg)*DEG_TO_RAD)
/**
* @ingroup Maths
* @brief Converts radians to degrees.
* @param rad The angle in radians.
* @return The angle in degrees.
*/
#define degrees(rad) ((rad)*RAD_TO_DEG)
/**
* @ingroup Maths
* @brief Squares a number.
* @param x The number to square.
* @return The squared value.
*/
#define sq(x) ((x)*(x)) /* x^2 */
/**
* @brief No Operation.
* @details Performs no operation. Used as a placeholder or for creating short delays.
*/
#define _NOP() do { __asm__ volatile ("nop"); } while (0)
#ifdef F_CPU
/**
* @brief Gets the number of clock cycles per microsecond.
* @return The number of clock cycles per microsecond.
*/
#define clockCyclesPerMicrosecond() (F_CPU / 1000000L)
/**
* @brief Converts clock cycles to microseconds.
* @param a The number of clock cycles.
* @return The corresponding number of microseconds.
*/
#define clockCyclesToMicroseconds(a) ((a) / clockCyclesPerMicrosecond())
/**
* @brief Converts microseconds to clock cycles.
* @param a The number of microseconds.
* @return The corresponding number of clock cycles.
*/
#define microsecondsToClockCycles(a) ((a) * clockCyclesPerMicrosecond())
#elif !defined(RTDUINO_TINY_MODE)
/**
* @warning Please define F_CPU in pins_arduino.h
*/
#warning "Please define F_CPU in pins_arduino.h"
#endif /* F_CPU */
/**
* @ingroup Bits and Bytes
* @brief Computes the value of the specified bit (bit 0 is 1, bit 1 is 2, bit 2 is 4, etc.).
* @param b The bit whose value to compute. Note that n needs to be between 0-31 (32 bit).
* @return The value of the specified bit.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bit
*/
#define bit(b) (1UL << (b))
/**
* @ingroup Bits and Bytes
* @brief Reads the value of a specific bit.
* @param value The number from which to read.
* @param bit Which bit to read, starting at 0 for the least-significant (rightmost) bit.
* @return The value of the specified bit (0 or 1).
* @details
* Reads a bit of a variable, e.g. bool, int. Note that float & double are not supported. You can read the bit of variables up to an unsigned long long (64 bits / 8 bytes).
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitread
*/
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
/**
* @ingroup Bits and Bytes
* @brief Sets a specific bit.
* @param value The number in which to set a bit.
* @param bit Which bit to set, starting at 0 for the least-significant (rightmost) bit.
* @return The value of the numeric variable after the bit at position n is set.
* @details
* Sets a bit of a variable, e.g. bool, int. Note that float & double are not supported. You can set the bit of variables up to an unsigned long long (64 bits / 8 bytes).
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitset
*/
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
/**
* @ingroup Bits and Bytes
* @brief Clears a specific bit.
* @param value The number in which to clear a bit.
* @param bit Which bit to clear, starting at 0 for the least-significant (rightmost) bit.
* @return The value of the numeric variable after the bit at position n is cleared.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitclear
*/
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
/**
* @ingroup Bits and Bytes
* @brief Toggles a specific bit.
* @param value The number in which to toggle a bit.
* @param bit Which bit to toggle, starting at 0 for the least-significant (rightmost) bit.
* @return The value of the numeric variable after the bit at position n is toggled.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bittoggle
*/
#define bitToggle(value, bit) ((value) ^= (1UL << (bit)))
/**
* @ingroup Bits and Bytes
* @brief Writes a specific bit.
* @param value The number in which to write a bit.
* @param bit Which bit to write, starting at 0 for the least-significant (rightmost) bit.
* @param bitvalue The value to write (0 or 1).
* @return The value of the numeric variable after the specified bit is written.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/bitwrite
*/
#define bitWrite(value, bit, bitvalue) ((bitvalue) ? bitSet(value, bit) : bitClear(value, bit))
/**
* @ingroup Bits and Bytes
* @brief Extracts the low-order (rightmost) byte of a variable (e.g. a word).
* @param w A value of any type.
* @return The low-order (rightmost) byte of the value.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/lowbyte
*/
#define lowByte(w) ((uint8_t) ((w) & 0xff))
/**
* @ingroup Bits and Bytes
* @brief Extracts the high-order (leftmost) byte of a word (or the second lowest byte of a larger data type).
* @param w A value of any type.
* @return The high-order (leftmost) byte of the value.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/highbyte
*/
#define highByte(w) ((uint8_t) ((w) >> 8))
/**
* @ingroup Digital I/O
* @brief Configures the specified pin to behave either as an input or an output.
* @param pin The number of the pin to be configured.
* @param mode The mode to set for the pin (INPUT, OUTPUT, INPUT_PULLUP, INPUT_PULLDOWN, OUTPUT_OPEN_DRAIN).
* @note
* This function can only be used for digitalRead() and digitalWrite().<br>
* For analogRead() or analogWrite(), please **DO NOT** use this function to configure the pin.
* @see https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode
*/
void pinMode(uint8_t pin, uint8_t mode);
/**
* @ingroup Digital I/O
* @brief Writes a HIGH or a LOW value to a digital pin.
* @param pin The number of the pin to write to.
* @param val The value to write (HIGH or LOW).
* @see https://www.arduino.cc/reference/en/language/functions/digital-io/digitalwrite
*/
void digitalWrite(uint8_t pin, uint8_t val);
/**
* @ingroup Digital I/O
* @brief Reads the value from a specified digital pin, either HIGH or LOW.
* @param pin The number of the pin to read from.
* @return The value read from the pin (HIGH or LOW).
* @see https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread
*/
int digitalRead(uint8_t pin);
/**
* @ingroup Analog I/O
* @brief Reads the analog input on a specified analog pin.
* @param pin The number of the analog input pin.
* @return The analog value read from the pin.
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogread
*/
int analogRead(uint8_t pin);
/**
* @ingroup Analog I/O
* @brief Writes an analog value (PWM wave) to a pin.
* @param pin The number of the PWM pin.
* @param val The duty cycle: between 0 (always off) and 255 (always on).
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite
*/
void analogWrite(uint8_t pin, int val);
/**
* @ingroup Analog I/O
* @brief Configures the reference voltage used for analog input (e.g., external, internal, etc.).
* @param mode The type of reference (e.g., DEFAULT, INTERNAL, EXTERNAL).
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference
*/
void analogReference(uint8_t mode);
/**
* @ingroup Analog I/O
* @brief Sets the number of bits of resolution for the analogRead function.
* @param bits The number of bits (e.g., 8, 10, 12) for the resolution.
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogreadresolution
*/
void analogReadResolution(uint8_t bits);
/**
* @ingroup Analog I/O
* @brief Sets the number of bits of resolution for the analogWrite function.
* @param bits The number of bits (e.g., 8, 10, 12) for the resolution.
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogwriteresolution
*/
void analogWriteResolution(uint8_t bits);
/**
* @ingroup Analog I/O
* @brief Sets the frequency of the PWM on a pin.
* @param frequency The desired frequency in Hertz (cycles per second).
* @see https://www.arduino.cc/reference/en/language/functions/analog-io/analogwritefrequency
*/
void analogWriteFrequency(uint32_t frequency);
/**
* @ingroup Time
* @brief Pauses the execution of the current task, allowing other tasks to run.
* @details
* The `yield` function is used to pause the execution of the current task, giving
* the RT-Thread scheduler an opportunity to run other tasks. This function is typically
* used in scenarios where a task voluntarily relinquishes control to the scheduler,
* allowing a cooperative multitasking system.
*
* When a task calls `yield`, it enters a waiting state, and the scheduler may choose
* to run another task that is ready to execute. After yielding, the task that called
* `yield` may be scheduled to run again in the future.
*
* @note
* - This function is essential for cooperative multitasking, where tasks voluntarily
* relinquish control to the scheduler.
* - In preemptive multitasking systems, tasks yield control based on the scheduler's
* predefined time slices.
* - The behavior of `yield` can vary depending on the underlying RT-Thread configuration
* and scheduler settings.
*
* @see https://www.arduino.cc/reference/en/language/functions/scheduler/yield
*/
void yield(void);
/**
* @ingroup Time
* @brief Delays the program for the specified number of milliseconds.
* @param ms The number of milliseconds to delay.
* @see https://www.arduino.cc/reference/en/language/functions/time/delay
*/
void delay(unsigned long ms);
/**
* @ingroup Time
* @brief Delays the program for the specified number of microseconds.
* @param us The number of microseconds to delay.
* @see https://www.arduino.cc/reference/en/language/functions/time/delaymicroseconds
*/
void delayMicroseconds(unsigned int us);
/**
* @ingroup Time
* @brief Returns the number of milliseconds since the Arduino board began running the current program.
* @return The number of milliseconds since program start.
* @see https://www.arduino.cc/reference/en/language/functions/time/millis
*/
unsigned long millis(void);
/**
* @ingroup Time
* @brief Returns the number of microseconds since the Arduino board began running the current program.
* @return The number of microseconds since program start.
* @see https://www.arduino.cc/reference/en/language/functions/time/micros
*/
unsigned long micros(void);
/**
* @ingroup Advanced I/O
* @brief Measures the duration of a pulse (in us) on the specified pin.
* @details
* The state parameter specifies the type of pulse to measure (HIGH or LOW).
* The timeout parameter specifies the maximum time to wait for the pulse to complete.
* This function works on pulses from 2-3 microseconds to 3 minutes in length.
* It cannot work in noInterrupt() context.
* @param pin The pin number to measure the pulse on.
* @param state The type of pulse to measure (HIGH or LOW).
* @param timeout The maximum time to wait for the pulse to complete, in microseconds.
* @return The duration of the pulse in microseconds, or 0 if no pulse starts before the timeout.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein
*/
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
/**
* @ingroup Advanced I/O
* @brief Measures the duration of a pulse (in us) on the specified pin.
* @details
* The state parameter specifies the type of pulse to measure (HIGH or LOW).
* The timeout parameter specifies the maximum time to wait for the pulse to complete.
* This function works on pulses from 2-3 microseconds to 3 minutes in length.
* It relies on the micros() function, so it cannot be used in noInterrupt() context.
* @param pin The pin number to measure the pulse on.
* @param state The type of pulse to measure (HIGH or LOW).
* @param timeout The maximum time to wait for the pulse to complete, in microseconds.
* @return The duration of the pulse in microseconds, or 0 if no pulse starts before the timeout.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/pulseinlong
*/
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
/**
* @ingroup Advanced I/O
* @brief Sends out a byte of data on the specified data pin using the specified clock and bit order.
* @param dataPin The pin on which to output the data.
* @param clockPin The pin to toggle to signal the receiving device that the data is ready.
* @param bitOrder The order in which to send the bits (LSBFIRST or MSBFIRST).
* @param val The data byte to send.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftout
*/
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
/**
* @ingroup Advanced I/O
* @brief Shifts in data on a specified data pin using a specified clock pin and bit order.
* @param dataPin The pin on which to read the incoming data.
* @param clockPin The pin to toggle to signal the sending device that the Arduino is ready to receive the next bit.
* @param bitOrder The order in which to receive the bits (LSBFIRST or MSBFIRST).
* @return The received data byte.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/shiftin
*/
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
/**
* @ingroup Interrupts
* @brief Enables interrupts, allowing the execution of interrupt service routines.
* @see https://www.arduino.cc/reference/en/language/functions/interrupts/interrupts
*/
void interrupts(void);
/**
* @ingroup Interrupts
* @brief Disables interrupts, preventing the execution of interrupt service routines.
* @see https://www.arduino.cc/reference/en/language/functions/interrupts/nointerrupts
*/
void noInterrupts(void);
/**
* @ingroup External Interrupts
* @brief Converts a digital pin number to the corresponding interrupt number.
* @param pin The digital pin number.
* @return The corresponding interrupt number, or NOT_AN_INTERRUPT if the pin does not support interrupts.
* @see https://www.arduino.cc/reference/en/language/functions/external-interrupts/digitalpintointerrupt
*/
uint8_t digitalPinToInterrupt(uint8_t pin);
/**
* @ingroup External Interrupts
* @brief Attaches an interrupt service routine to a specified interrupt.
* @param interruptNum The interrupt number to attach the ISR to.
* @param userFunc The function to call when the interrupt occurs.
* @param mode The type of interrupt to attach the ISR to (e.g., CHANGE, FALLING, RISING).
* @see https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt
*/
void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode);
/**
* @ingroup External Interrupts
* @brief Detaches an interrupt service routine from a specified interrupt.
* @param interruptNum The interrupt number to detach the ISR from.
* @see https://www.arduino.cc/reference/en/language/functions/external-interrupts/detachinterrupt
*/
void detachInterrupt(uint8_t interruptNum);
/**
* @ingroup Random Numbers
* @brief Initializes the pseudo-random number generator.
* @param seed The seed value for the random number generator.
* @see https://www.arduino.cc/reference/en/language/functions/random-numbers/randomseed
*/
void randomSeed(unsigned long seed);
/**
* @ingroup Maths
* @brief Maps a value from one range to another.
* @param x The value to map.
* @param in_min The lower bound of the input range.
* @param in_max The upper bound of the input range.
* @param out_min The lower bound of the output range.
* @param out_max The upper bound of the output range.
* @return The mapped value.
* @see https://www.arduino.cc/reference/en/language/functions/math/map
*/
long map(long x, long in_min, long in_max, long out_min, long out_max);
/**
* @ingroup System
* @brief Initialization function for the Arduino environment.
* @details This function should be called at the beginning of the program to set up the Arduino environment.
* @see https://www.arduino.cc/reference/en/language/structure/sketch/setup
*/
void setup(void);
/**
* @ingroup System
* @brief Main loop function for the Arduino program.
* @details This function is called repeatedly after the setup function, forming the main loop of the Arduino program.
* @see https://www.arduino.cc/reference/en/language/structure/sketch/loop
*/
void loop(void);
/**
* @ingroup System
* @brief Variant-specific initialization function.
* @details This function is called during the initialization process to set up variant-specific configurations.
* @note Do not call this function manually.
*/
void initVariant(void);
#ifdef RTDUINO_USING_SPI
/**
* @ingroup System
* @brief Switches to the SPI bus.
* @param bus_name The name of the SPI bus to switch to.
* @note Do not call this function manually.
*/
void switchToSPI(const char *bus_name);
#endif /* RTDUINO_USING_SPI */
#ifdef __cplusplus
} /* extern "C" { */
#endif
#ifdef __cplusplus
/**
* @ingroup Maths
* @brief Generates a random long integer within the specified range.
* @param max The upper bound of the range (exclusive).
* @return A random long integer.
* @see https://www.arduino.cc/reference/en/language/functions/random-numbers/random
*/
long random(long max);
/**
* @ingroup Random numbers
* @brief Generates a random long integer within the specified range.
* @param min The lower bound of the range.
* @param max The upper bound of the range (exclusive).
* @return A random long integer.
* @see https://www.arduino.cc/reference/en/language/functions/random-numbers/random
*/
long random(long min, long max);
/**
* @ingroup Maths
* @brief Maps a value from one range to another range.
*
* This template function maps a number from one range to another range, maintaining the ratio of the input range
* to output range. It can be used with any data type that supports arithmetic operations (e.g., int, float, double).
*
* @tparam T The data type of the input and output values. Must support arithmetic operations.
* @param x The number to map.
* @param in_min The lower bound of the input range.
* @param in_max The upper bound of the input range.
* @param out_min The lower bound of the output range.
* @param out_max The upper bound of the output range.
*
* @return The mapped value of type T.
*
* @code
* int input = 10;
* int output = map<int>(input, 0, 100, -50, 50); // Maps 10 from range 0-100 to -40 in range -50 to 50
* @endcode
*
* @see https://www.arduino.cc/reference/en/language/functions/math/map
*/
template <typename T>
T map(T x, T in_min, T in_max, T out_min, T out_max)
{
return (T)(((double)(x - in_min) * (double)(out_max - out_min)) / (double)((in_max - in_min) + out_min));
}
/**
* @ingroup Conversion
* @brief Combines two bytes into a word.
* @param w The high byte.
* @return The combined word.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/makeword
*/
uint16_t makeWord(uint16_t w);
/**
* @ingroup Conversion
* @brief Combines two bytes into a word.
* @param h The high byte.
* @param l The low byte.
* @return The combined word.
* @see https://www.arduino.cc/reference/en/language/functions/bits-and-bytes/makeword
*/
uint16_t makeWord(byte h, byte l);
/**
* @ingroup Conversion
* @brief Converts a value to the word data type.
* @see https://www.arduino.cc/reference/en/language/variables/conversion/wordcast
*/
#define word(...) makeWord(__VA_ARGS__)
/**
* @ingroup Advanced I/O
* @brief Measures the duration of a pulse on the specified pin.
* @param pin The number of the pin on which to measure the pulse.
* @param state The type of pulse to measure (e.g., HIGH, LOW, CHANGE, FALLING, RISING).
* @param timeout The maximum duration to wait for the pulse, in microseconds.
* @return The duration of the pulse in microseconds, or 0 if no pulse starts before the timeout.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/pulsein
*/
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
/**
* @ingroup Advanced I/O
* @brief Measures the duration of a pulse on the specified pin.
* @param pin The number of the pin on which to measure the pulse.
* @param state The type of pulse to measure (e.g., HIGH, LOW, CHANGE, FALLING, RISING).
* @param timeout The maximum duration to wait for the pulse, in microseconds.
* @return The duration of the pulse in microseconds, or 0 if no pulse starts before the timeout.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/pulseinlong
*/
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
/**
* @ingroup Advanced I/O
* @brief Generates a square wave of the specified frequency (and 50% duty cycle) on a pin.
* @param pin The number of the pin on which to output the tone.
* @param frequency The frequency of the square wave in hertz.
* @param duration The duration of the tone in milliseconds (optional).
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/tone
*/
void tone(uint8_t pin, unsigned int frequency, unsigned long duration = 0);
/**
* @ingroup Advanced I/O
* @brief Stops the generation of a square wave previously started by the tone() function.
* @param pin The number of the pin on which to stop the tone.
* @see https://www.arduino.cc/reference/en/language/functions/advanced-io/notone
*/
void noTone(uint8_t pin);
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
#ifdef RTDUINO_USING_USBSERIAL
#include "USBSerial.h"
#endif /* RTDUINO_USING_USBSERIAL */
#endif /* __cplusplus */
/* low level test functions */
#if defined(RTDUINO_USING_UTEST) || defined(RT_UTEST_USING_ALL_CASES)
#include "utest/TC_LLT.h"
#endif /* RTDUINO_USING_UTEST || RT_UTEST_USING_ALL_CASES */
#endif /* __ARDUINO_CORE_H__ */
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

RT-Thread的Arduino生态兼容层
取消

发行版 (1)

全部

开源评估指数源自 OSS-Compass 评估体系,评估体系围绕以下三个维度对项目展开评估:

1. 开源生态

  • 生产力:来评估开源项目输出软件制品和开源价值的能力。
  • 创新力:用于评估开源软件及其生态系统的多样化程度。
  • 稳健性:用于评估开源项目面对多变的发展环境,抵御内外干扰并自我恢复的能力。

2. 协作、人、软件

  • 协作:代表了开源开发行为中协作的程度和深度。
  • 人:观察开源项目核心人员在开源项目中的影响力,并通过第三方视角考察用户和开发者对开源项目的评价。
  • 软件:从开源项目对外输出的制品评估其价值最终落脚点。也是开源评估最"古老"的主流方向之一"开源软件" 的具体表现。

3. 评估模型

    基于"开源生态"与"协作、人、软件"的维度,找到与该目标直接或间接相关的可量化指标,对开源项目健康与生态进行量化评估,最终形成开源评估指数。

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/rtduino/RTduino.git
git@gitee.com:rtduino/RTduino.git
rtduino
RTduino
RTduino
master
点此查找更多帮助

搜索帮助

仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /