-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock platform #949
base: master
Are you sure you want to change the base?
Mock platform #949
Changes from all commits
54e9fc7
d383c4c
d3f7e65
15b4384
b7e348c
b116331
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,18 @@ extern "C" { | |
|
||
#include "mraa_internal.h" | ||
|
||
#define MRAA_MOCK_PINCOUNT 10 | ||
#define MRAA_MOCK_GPIO_COUNT 1 | ||
#define MRAA_MOCK_AIO_COUNT 1 | ||
#define MRAA_MOCK_I2C_BUS_COUNT 1 | ||
#define MRAA_MOCK_SPI_BUS_COUNT 1 | ||
#define MRAA_MOCK_PWM_DEV_COUNT 1 | ||
#define MRAA_MOCK_UART_DEV_COUNT 1 | ||
#define MRAA_MOCK_PINCOUNT (MRAA_MOCK_GPIO_COUNT + MRAA_MOCK_AIO_COUNT + \ | ||
2 * MRAA_MOCK_I2C_BUS_COUNT + 4 * MRAA_MOCK_SPI_BUS_COUNT + \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: shis and line below need one more space to align on opening |
||
MRAA_MOCK_PWM_DEV_COUNT + 2 * MRAA_MOCK_UART_DEV_COUNT) | ||
|
||
#define MRAA_PWM_OFFSET (MRAA_MOCK_GPIO_COUNT + MRAA_MOCK_AIO_COUNT + \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this a base for |
||
2 * MRAA_MOCK_I2C_BUS_COUNT + 4 * MRAA_MOCK_SPI_BUS_COUNT) | ||
|
||
mraa_board_t* | ||
mraa_mock_board(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ extern "C" { | |
// Mock I2C device address | ||
#define MOCK_I2C_DEV_ADDR 0x33 | ||
// Mock I2C device data registers block length in bytes. Our code assumes it's >= 1. | ||
#define MOCK_I2C_DEV_DATA_LEN 10 | ||
#define MOCK_I2C_DEV_DATA_LEN 255 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
// Initial value for each byte in the mock I2C device data registers | ||
#define MOCK_I2C_DEV_DATA_INIT_BYTE 0xAB | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Author: Adelin Dobre <[email protected]> | ||
* Copyright (c) 2019 Adelin Dobre. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include "mraa_internal.h" | ||
|
||
mraa_result_t | ||
mraa_mock_pwm_init_raw_replace(mraa_pwm_context dev, int pin); | ||
|
||
mraa_result_t | ||
mraa_mock_pwm_write_period_replace(mraa_pwm_context dev, int period); | ||
|
||
mraa_result_t | ||
mraa_mock_pwm_write_duty_replace(mraa_pwm_context dev, int duty); | ||
|
||
int | ||
mraa_mock_pwm_read_duty_replace(mraa_pwm_context dev); | ||
|
||
mraa_result_t | ||
mraa_mock_pwm_enable_replace(mraa_pwm_context dev, int enable); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the mock platform description in
docs
accordingly, right now the PWM functionality and the extra pin are not mentioned.