Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • e-24/public/ahoi/firmware
1 result
Show changes
Showing
with 115 additions and 26 deletions
......@@ -55,7 +55,7 @@
* public functions
*/
void
bool
aci_test_freq_processCmd(const mm_packet_t * pkt)
{
aci_test_freq_cmd_t * p = (aci_test_freq_cmd_t *)pkt->payload;
......@@ -64,14 +64,14 @@ aci_test_freq_processCmd(const mm_packet_t * pkt)
fp16_t gain = FP_ONE;
if (pkt->header.len != sizeof(aci_test_freq_cmd_t)) {
return;
return false;
}
// obtain and check parameter
// convert multiple of frequency spacing to index in table (n = idx+1)
idx = FREQ_IDX( p->freqNum );
if (idx >= FREQ_LIST_NUM) {
return;
return false;
}
if (p->lvl == 0) {
......@@ -99,6 +99,8 @@ aci_test_freq_processCmd(const mm_packet_t * pkt)
// return to rx mode
adda_activateSampling();
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* send frequency (one symbol duration)
*/
extern void
extern bool
aci_test_freq_processCmd(const mm_packet_t * pkt);
extern uint8_t
......
......@@ -54,7 +54,7 @@
* public functions
*/
void
bool
aci_test_noise_processCmd(const mm_packet_t * pkt)
{
uint16_t i, j;
......@@ -65,7 +65,7 @@ aci_test_noise_processCmd(const mm_packet_t * pkt)
// sanity check
if (pkt->header.len != sizeof(aci_test_noise_cmd_t)) {
return;
return false;
}
// obtain and check parameters
......@@ -115,6 +115,8 @@ aci_test_noise_processCmd(const mm_packet_t * pkt)
// return to rx mode
adda_activateSampling();
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* send all symbols one by one
*/
extern void
extern bool
aci_test_noise_processCmd(const mm_packet_t * pkt);
extern uint8_t
......
......@@ -133,7 +133,7 @@ static const fp16_t FREQ_TEST_SOUND[TX_SAMPLES_PER_SYMBOL] = {
* public functions
*/
void
bool
aci_test_sound_processCmd(const mm_packet_t * pkt)
{
uint16_t i, j;
......@@ -142,7 +142,7 @@ aci_test_sound_processCmd(const mm_packet_t * pkt)
// sanity check
if (pkt->header.len != sizeof(aci_test_sound_cmd_t)) {
return;
return false;
}
// obtain and check parameters
......@@ -172,6 +172,8 @@ aci_test_sound_processCmd(const mm_packet_t * pkt)
// return to rx mode
adda_activateSampling();
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* send
*/
extern void
extern bool
aci_test_sound_processCmd(const mm_packet_t * pkt);
extern uint8_t
......
......@@ -58,7 +58,7 @@
* public functions
*/
void
bool
aci_test_sweep_processCmd(const mm_packet_t * pkt)
{
uint8_t idx;
......@@ -66,7 +66,7 @@ aci_test_sweep_processCmd(const mm_packet_t * pkt)
// sanity check
if (pkt->header.len != sizeof(aci_test_sweep_cmd_t)) {
return;
return false;
}
// obtain and check parameter
......@@ -100,6 +100,8 @@ aci_test_sweep_processCmd(const mm_packet_t * pkt)
// return to rx mode
adda_activateSampling();
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* send all symbols one by one
*/
extern void
extern bool
aci_test_sweep_processCmd(const mm_packet_t * pkt);
extern uint8_t
......
......@@ -57,12 +57,14 @@
* public functions
*/
void
bool
aci_transducer_processCmd(const mm_packet_t * pkt)
{
// optional action, always return current state
if (pkt->header.len == sizeof(aci_transducer_cmd_t)) {
freq_setTransducer(((aci_transducer_cmd_t *)pkt->payload)->type);
}
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* gets/sets transducer type (index)
*/
extern void
extern bool
aci_transducer_processCmd(const mm_packet_t * pkt);
extern uint8_t
......
......@@ -71,15 +71,17 @@ aci_txgain_fillReply(uint8_t * payload)
* public functions
*/
void
bool
aci_txgain_processCmd(const mm_packet_t * pkt)
{
#ifndef SIM
// optional action, always return current state
if (pkt->header.len == sizeof(aci_txgain_cmd_t)) {
aci_txgain_cmd_t * p = (aci_txgain_cmd_t *)(pkt->payload);
txamp_setGainLevel(p->lvl);
}
#endif
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* change tx gains
*/
extern void
extern bool
aci_txgain_processCmd(const mm_packet_t * pkt);
......
......@@ -60,9 +60,11 @@
* public functions
*/
void
bool
aci_version_processCmd(__attribute__ ((unused)) const mm_packet_t * pkt)
{
// read-only
return true;
}
......
......@@ -43,7 +43,7 @@
/**
* get firmware version
*/
extern void
extern bool
aci_version_processCmd(const mm_packet_t * pkt);
......
......@@ -50,6 +50,9 @@ CFLAGS += -DPIN_DEBUG
# CFLAGS += -DSAMPLING_FREQ=FREQ_200kHz
# CFLAGS += -DRX_DOWNSAMPLE=RX_SAMPLING_DIV1
# enable sleep mode (with external wake-up)
# CFLAGS += -DSLEEP_ENABLE
# enable ACI sample command
CFLAGS += -DACI_SAMPLE_ENABLE
......
/**
* Copyright 2016-2019
* Copyright 2016-2024
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -39,9 +39,21 @@
#include <stdint.h>
// generator polynomes
#define CRC8_GENERATOR 0xD5 // CRC-8: x^8+x^7+x^6+x^4+x^2+x^0
#define CRC16_GENERATOR 0x8005 // IBM-CRC-16: x^16+x^15+x^2+x^0
// generator polynoms
// choices basd on:
// Philip Koopman and Tridib Chakravarty. Cyclic Redundancy Code (CRC)
// Polynomial Selection For Embedded Networks. The International
// Conference on Dependable Systems and Networks, DSN-2004.
// https://users.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf
// ideal for up to 97 bit (HD=4)
#define CRC8_GENERATOR 0x97
// ideal for up to 2048 bit (HD=4)
#define CRC16_GENERATOR 0xBAAD
#define CRC8_MAX_LEN (97/8) // decider for CRC-8 vs. CRC-16 in bytes
// computes the CRC8 checksum for the header
uint8_t crc_CRC8(const uint8_t * const data, uint8_t len);
......
/**
* Copyright 2016-2020
* Copyright 2016-2024
*
* Bernd-Christian Renner, and
* Hamburg University of Technology (TUHH).
......@@ -77,7 +77,6 @@
#define PAYLOAD_BLOCKS(l) ((PAYLOAD_TOTAL_LEN(l) * 8 + PAYLOAD_DEC_BITS_PER_BLOCK - 1) / PAYLOAD_DEC_BITS_PER_BLOCK)
// maximum number of payload blocks
//#define PAYLOAD_MAX_BLOCKS (PAYLOAD_BLOCKS(MM_PAYLOAD_MAXLEN + MM_PAYLOAD_CRC_LEN))
#define PAYLOAD_MIN_DEC_BITS_PER_BLOCK 4
#define PAYLOAD_MAX_BLOCKS ((MAX_PAYLOAD_TOTAL_LEN * 8 + PAYLOAD_MIN_DEC_BITS_PER_BLOCK - 1) / PAYLOAD_MIN_DEC_BITS_PER_BLOCK)
......
......@@ -50,6 +50,10 @@
void
adda_init(void);
/* disable both rx and tx */
void
adda_powerDown(void);
/* activate rx (reading from ADC) */
void
adda_activateSampling(void);
......
/**
* Copyright 2024
*
* Bernd-Christian Renner and
* Hamburg University of Technology (TUHH).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef HAL_SLEEP_H_
#define HAL_SLEEP_H_
#include <stdbool.h>
#if defined SLEEP_ENABLE && ! defined SIM
void
hal_checkSleep(void);
bool
hal_requestSleep(void);
#else
# define hal_checkSleep(...)
# define hal_requestSleep(...) false
#endif
#endif
/**
* Copyright 2016-2018
* Copyright 2016-2024
*
* Timo Kortbrae,
* Jan Heitmann,
......@@ -43,4 +43,8 @@
void board_init(void);
void board_enterPowerDownMode(void);
void board_trySleep(void);
#endif