-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from arkedge/feature/add-hal-noop-impl
Add HAL noop implementation
- Loading branch information
Showing
9 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "c2a-i2c-noop" | ||
description = "No-op c2a-hal I2C implementation for mock" | ||
version.workspace = true | ||
edition = "2021" | ||
|
||
[dependencies] | ||
c2a-core.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#![no_std] | ||
|
||
use core::ffi::{c_int, c_void}; | ||
|
||
use c2a_core::hal::i2c::*; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_init(_i2c_config: *mut I2C_Config) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_rx( | ||
_i2c_config: *mut I2C_Config, | ||
_data: *mut c_void, | ||
_buffer_size: c_int, | ||
) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_tx( | ||
_i2c_config: *mut I2C_Config, | ||
_data: *mut c_void, | ||
_data_size: c_int, | ||
) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_reopen(_i2c_config: *mut I2C_Config, _reason: c_int) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_set_stop_flag(_i2c_config: *mut I2C_Config, _stop_flag: u8) {} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn I2C_set_rx_length(_i2c_config: *mut I2C_Config, _rx_length: u32) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "c2a-spi-noop" | ||
description = "No-op c2a-hal SPI implementation for mock" | ||
version.workspace = true | ||
edition = "2021" | ||
|
||
[dependencies] | ||
c2a-core.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#![no_std] | ||
|
||
use core::ffi::{c_int, c_void}; | ||
|
||
use c2a_core::hal::spi::*; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_init(_spi_config: *mut SPI_Config) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_rx( | ||
_spi_config: *mut SPI_Config, | ||
_data: *mut c_void, | ||
_buffer_size: c_int, | ||
) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_tx( | ||
_spi_config: *mut SPI_Config, | ||
_data: *mut c_void, | ||
_data_size: c_int, | ||
) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_reopen(_spi_config: *mut SPI_Config, _reason: c_int) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_set_rx_length(_spi_config: *mut SPI_Config, _rx_length: u16) {} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn SPI_set_cs_state_after_tx( | ||
_spi_config: *mut SPI_Config, | ||
_cs_state_after_tx: SPI_CS_STATE_AFTER_TX, | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "c2a-uart-noop" | ||
description = "No-op c2a-hal UART implementation for mock" | ||
version.workspace = true | ||
edition = "2021" | ||
|
||
[dependencies] | ||
c2a-core.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#![no_std] | ||
|
||
use core::ffi::{c_int, c_void}; | ||
|
||
use c2a_core::hal::uart::*; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn UART_init(_uart_config: *mut UART_Config) -> c_int { | ||
UART_ERR_CODE_UART_OK.0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn UART_rx( | ||
_uart_config: *mut UART_Config, | ||
_data: *mut c_void, | ||
_buffer_size: c_int, | ||
) -> c_int { | ||
UART_ERR_CODE_UART_OK.0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn UART_tx( | ||
_uart_config: *mut UART_Config, | ||
_data: *mut c_void, | ||
_data_size: c_int, | ||
) -> c_int { | ||
UART_ERR_CODE_UART_OK.0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn UART_reopen(_uart_config: *mut UART_Config, _reason: c_int) -> c_int { | ||
UART_ERR_CODE_UART_OK.0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "c2a-wdt-noop" | ||
description = "No-op c2a-hal WDT implementation for mock" | ||
version.workspace = true | ||
edition = "2021" | ||
|
||
[dependencies] | ||
c2a-core.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#![no_std] | ||
#![allow(clippy::missing_safety_doc)] | ||
|
||
use core::ffi::c_int; | ||
|
||
use c2a_core::hal::wdt::*; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn WDT_initialize(config: *mut WDT_Config) -> c_int { | ||
let cfg = unsafe { &mut (*config) }; | ||
|
||
WDT_set_timer(config, 7); | ||
|
||
cfg.is_clear_enable = 1; | ||
cfg.is_wdt_enable = 1; | ||
|
||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn WDT_clear(_wdt_config: *mut WDT_Config) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn WDT_enable(_wdt_config: *mut WDT_Config) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub extern "C" fn WDT_disable(_wdt_config: *mut WDT_Config) -> c_int { | ||
0 | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn WDT_set_timer(config: *mut WDT_Config, time: c_int) -> c_int { | ||
let cfg = unsafe { &mut (*config) }; | ||
|
||
cfg.timer_setting = time; | ||
|
||
0 | ||
} |