Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mmwave
# MMWAVE

The MMWCAS-RF-EVM and MMWCAS-DSP-EVM boards from Texas Instruments (TI) are supported
with the TI-provided software `mmwave studio`. As so, one needs a Windows OS and Matlab
Expand Down Expand Up @@ -35,23 +35,23 @@ You can first check if `mmwave` is properly installed by typing the `help` comma
mmwave -h
```

You shall the see a help menu similar to the one below.
You shall see a help menu similar to the one below.

```txt
usage: mmwave [-d] [-p] [-i] [-c] [-r] [-t] [-f] [-h] [-v]

Configuration and control tool for TI MMWave cascade Evaluation Module

options:
-d, --capture-dir Name of the director where to store recordings on the DSP board
-p, --port Port number the DSP board server app is listening on
-i, --ip-addr IP Address of the MMWCAS DSP evaluation module
-c, --configure Configure the MMWCAS-RF-EVM board
-r, --record Trigger data recording. This assumes that configuration is completed.
-t, --time Indicate how long the recording should last in minutes. Default: 1 min
-f, --cfg TOML Configuration file. Overwrite the default config when provided
-h, --help Print CLI option help and exit.
-v, --version Print program version and exit.
usage: mmwave [command] [option]

Configuration and control tool for TI MMWave Evaluation Modules

Arguments:
configure Configure the MMWCAS-RF-EVM board
record Trigger data recording. This assumes that configuration is completed.
-d, --capture-dir Name of the director where to store recordings on the DSP board
-p, --port Port number the DSP board server app is listening on
-i, --ip IP Address of the MMWCAS DSP evaluation module
-t, --time Indicate how long the recording should last in minutes. Default: 1 min
-f, --cfg TOML Configuration file. Overwrite the default config when provided
-h, --help Print CLI option help and exit.
-v, --version Print program version and exit
```

A default configuration is already implemented (as described below) and can be used.
Expand All @@ -63,7 +63,7 @@ A default configuration is already implemented (as described below) and can be u
```

If the DSP board has been reconfigured with another IP address, you can provide the new
IP address in argument with the `--ip-addr` CLI option.
IP address in argument with the `--ip` CLI option.

## Recording data

Expand All @@ -72,10 +72,12 @@ IP address in argument with the `--ip-addr` CLI option.
To record data, the typical command is:

```bash
mmwave -d <directory> --configure --record --time <duriation-in-minute>
mmwave configure
mmwave record -d <directory> --time <duriation-in-minute>

# Exmaple
mmwave -d outdoor0 --configure --record --time 10
mmwave configure
mmwave record -d outdoor0 --time 10
```

With this command, the radar chips are configured with the default configuration
Expand Down Expand Up @@ -114,22 +116,24 @@ dataFmt:
```

If the capture directory is not indicated (with the `-d` option), the capture folder is
automatically created as `MMW_Capture_<timestamp>`; with `<timesamp>` is placeholder for
automatically created as `MMW_Capture_<timestamp>`; with `<timesamp>` a placeholder for
the Unix timestamp at which the command has been issued.

### Self-defined configuration

It's possible to define custom configurations suitable for a given recording setup
with TOML config files. Some examples of config files are present on the `config`
with TOML config files. Some examples of config files are present in the `config`
folder of this repository.

With a config file, one can use the command below:
With a config file, one can use the commands below:

```bash
mmwave -f <path-to-config-file> --configure --record --time <duration-in-min>
mmwave configure -f <path-to-config-file>
mmwave record -f <path-to-config-file> --time <duration-in-min>

# Example
mmwave -f config/short-range-cfg.toml --configure --record --time 2
mmwave configure -f config/short-range-cfg.toml
mmwave record -f config/short-range-cfg.toml --time 2
```

### Check and copy recorded data
Expand Down Expand Up @@ -206,20 +210,23 @@ The structure of the repository is as follows:
```

The content of the folders `ti/mmwavelink` and `ti/firmware` must not be modified. Those
are respectively libraries and firmware provided by Texas Instruments and should not be
modified unless one knows what it's all about. Any update to those can be directly obtained
from TI or by copying them from the installation folder of `mmwave studio` and
`mmwave dfp`.
are respectively libraries and firmware provided by Texas Instruments and should ideally not be
modified. Any update to those can be directly obtained from TI or by copying them from the installation
folder of `mmwave studio` and `mmwave dfp`.

The folders `ti/ethernet` and `ti/mmwave` are based on examples source files provided by
TI. Since the original sources were only compatible with windows, these have been modified
TI. Since the initial sources were only compatible with Windows OS, these have been modified
to operate on Linux OS. One can update these modules to extend the capabilities of this driver.

- The folder `opt` holds the source handling the CLI option parsing
- The `toml` folder handles the parsing of configuration files.
- The entry point of the program is in the `mimo.c` file.

**NOTE**: the files `toml/toml.c` and `toml/toml.h` have been authored by
**NOTE**:

* The files `toml/toml.c` and `toml/toml.h` have been authored by
[cktan](https://github.com/cktan) and released with an MIT license on Github at
https://github.com/cktan/tomlc99. Therefore, this reference is the perfect place to
seek for new updates of the `TOML` parser library.
seek new updates to the `TOML` parser library.

* See [opt](https://github.com/azinke/opt) for updates of the CLI parser
159 changes: 102 additions & 57 deletions mimo.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,17 @@ void check(int status, const char *success_msg, const char *error_msg,
}
}


/**
* @brief Initialize the master RADAR chip of the MMWCAS-RF-EVM board
*
* The configuration defines the number of channels to enbaled and the
* output format of the RADAR chips' ADC module. The patch firmware is also
* uploaded to the chip
*
* @param channelCfg Channel configuration
* @param adcOutCfg ADC configs
* @return int32_t Configuration status
*/
int32_t initMaster(rlChanCfg_t channelCfg, rlAdcOutCfg_t adcOutCfg) {
const unsigned int masterId = 0;
const unsigned int masterMap = 1 << masterId;
Expand Down Expand Up @@ -293,6 +303,17 @@ int32_t initMaster(rlChanCfg_t channelCfg, rlAdcOutCfg_t adcOutCfg) {
}


/**
* @brief Initialize the Slave RADAR chips of the MMWCAS-RF-EVM board
*
* The configuration defines the number of channels to enbaled and the
* output format of the RADAR chips' ADC module. The patch firmware is also
* uploaded to the chips
*
* @param channelCfg Channel configuration
* @param adcOutCfg ADC configs
* @return int32_t Configuration status
*/
int32_t initSlaves(rlChanCfg_t channelCfg, rlAdcOutCfg_t adcOutCfg) {
int status = 0;
uint8_t slavesMap = (1 << 1) | (1 << 2) | (1 << 3);
Expand Down Expand Up @@ -342,6 +363,12 @@ int32_t initSlaves(rlChanCfg_t channelCfg, rlAdcOutCfg_t adcOutCfg) {
}


/**
* @brief Handle the global configuration of the MMWCAS board
*
* @param config Device configuration
* @return uint32_t Configuration status
*/
uint32_t configure (devConfig_t config) {
int status = 0;
status += initMaster(config.channelCfg, config.adcOutCfg);
Expand Down Expand Up @@ -394,32 +421,6 @@ uint32_t configure (devConfig_t config) {
"[ALL] Chirp configuration successful!",
"[ALL] Chirp configuration failed!", config.deviceMap, TRUE);

// Master frame config.
status += MMWL_frameConfig(
config.masterMap,
config.frameCfg,
config.channelCfg,
config.adcOutCfg,
config.datapathCfg,
config.profileCfg
);
check(status,
"[MASTER] Frame configuration completed!",
"[MASTER] Frame configuration failed!", config.masterMap, TRUE);

// Slaves frame config
status += MMWL_frameConfig(
config.slavesMap,
config.frameCfg,
config.channelCfg,
config.adcOutCfg,
config.datapathCfg,
config.profileCfg
);
check(status,
"[SLAVE] Frame configuration completed!",
"[SLAVE] Frame configuration failed!", config.slavesMap, TRUE);

check(status,
"[MIMO] Configuration completed!\n",
"[MIMO] Configuration completed with error!", config.deviceMap, TRUE);
Expand All @@ -445,7 +446,7 @@ parser_t *g_parser = NULL;
* Print program version
*/
void print_version() {
printf(PROG_NAME " version " PROG_VERSION ", " PROG_COPYRIGHT "\n");
printf(PROG_NAME " " PROG_VERSION ", " PROG_COPYRIGHT "\n");
exit(0);
}

Expand Down Expand Up @@ -491,17 +492,32 @@ int main (int argc, char *argv[]) {
unsigned char default_capture_directory[64];
sprintf(default_capture_directory, "%s_%lu", "MMWL_Capture", (unsigned long int)time(NULL));
int status = 0;
// unsigned char vdefault = 0;
float default_recording_duration = 1.0; // min

parser_t parser = init_parser(
PROG_NAME,
"Configuration and control tool for TI MMWave cascade Evaluation Module"
"Configuration and control tool for TI MMWave Evaluation Modules"
);
g_parser = &parser;

atexit(cleanup); // Call the cleanup function before exiting the program
signal(SIGINT, signal_handler); // Catch CTRL+C to enable memory deallocation

option_t opt_config = {
.args = "configure",
.help = "Configure the MMWCAS-RF-EVM board",
.type = OPT_BOOL,
};
add_arg(&parser, &opt_config);

option_t opt_record = {
.args = "record",
.help = "Trigger data recording. This assumes that configuration is completed.",
.type = OPT_BOOL,
};
add_arg(&parser, &opt_record);

option_t opt_capturedir = {
.args = "-d",
.argl = "--capture-dir",
Expand All @@ -522,29 +538,13 @@ int main (int argc, char *argv[]) {

option_t opt_ipaddr = {
.args = "-i",
.argl = "--ip-addr",
.argl = "--ip",
.help = "IP Address of the MMWCAS DSP evaluation module",
.type = OPT_STR,
.default_value = default_ip_addr,
};
add_arg(&parser, &opt_ipaddr);

option_t opt_config = {
.args = "-c",
.argl = "--configure",
.help = "Configure the MMWCAS-RF-EVM board",
.type = OPT_BOOL,
};
add_arg(&parser, &opt_config);

option_t opt_record = {
.args = "-r",
.argl = "--record",
.help = "Trigger data recording. This assumes that configuration is completed.",
.type = OPT_BOOL,
};
add_arg(&parser, &opt_record);

option_t opt_record_duration = {
.args = "-t",
.argl = "--time",
Expand Down Expand Up @@ -590,20 +590,20 @@ int main (int argc, char *argv[]) {
exit(0);
}

unsigned char *ip_addr = (unsigned char*)get_option(&parser, "ip-addr");
unsigned int port = *(unsigned int*)get_option(&parser, "port");
unsigned char *capture_directory = (unsigned char*)get_option(&parser, "capture-dir");
unsigned char *ip_addr = (unsigned char*)get_option(&parser, "--ip");
unsigned int port = *(unsigned int*)get_option(&parser, "--port");
unsigned char *capture_directory = (unsigned char*)get_option(&parser, "--capture-dir");
strcat(capture_path, capture_directory);
/* Record CLI option possible values are:
* - start: To start a recording and exit
* - stop: Stop a recording and exit
* - oneshot: Start a recording, wait for it's complemention and stop it.
*/
unsigned char *record = (unsigned char*)get_option(&parser, "record");
float record_duration = *(float*)get_option(&parser, "time");
float record_duration = *(float*)get_option(&parser, "--time");
record_duration *= 60 * 1000; // convert into milliseconds

unsigned char *config_filename = (unsigned char*)get_option(&parser, "cfg");
unsigned char *config_filename = (unsigned char*)get_option(&parser, "--cfg");

// Configuration
devConfig_t config;
Expand Down Expand Up @@ -651,19 +651,58 @@ int main (int argc, char *argv[]) {
.dataPacking = 0, // 0: 16-bit | 1: 12-bit
};

if ((unsigned char *)get_option(&parser, "configure") != NULL) {
// Connect to TDA
status = MMWL_TDAInit(ip_addr, port, config.deviceMap);
check(status,
// Connect to TDA
status = MMWL_TDAInit(ip_addr, port);
check(status,
"[MMWCAS-DSP] TDA Connected!",
"[MMWCAS-DSP] Couldn't connect to TDA board!\n", 32, TRUE);

if ((unsigned char *)get_option(&parser, "configure") != NULL) {
// Configure Device Map and Initialize TDA peripherals
status = MMWL_ConfigureDeviveMap(config.deviceMap);
check(status,
"[MMWCAS-DSP] TDA Initialized!",
"[MMWCAS-DSP] Couldn't initialize the TDA board!\n", config.deviceMap, TRUE);

// Start configuration
configure(config);
msleep(2000);
msleep(1000);
}

if ((unsigned char *)get_option(&parser, "record") != NULL) {
else if ((unsigned char *)get_option(&parser, "record") != NULL) {
/**
* NOTE: Frame configurations define the application width and height that is
* needed to arm the TDA. Hence, these are done during the record command.
*
* When using a custom configuration file, it should also be provided in parameter
* when recording.
*/
// Master frame config.
status += MMWL_frameConfig(
config.masterMap,
config.frameCfg,
config.channelCfg,
config.adcOutCfg,
config.datapathCfg,
config.profileCfg
);
check(status,
"[MASTER] Frame configuration completed!",
"[MASTER] Frame configuration failed!", config.masterMap, TRUE);

// Slaves frame config
status += MMWL_frameConfig(
config.slavesMap,
config.frameCfg,
config.channelCfg,
config.adcOutCfg,
config.datapathCfg,
config.profileCfg
);
check(status,
"[SLAVE] Frame configuration completed!",
"[SLAVE] Frame configuration failed!", config.slavesMap, TRUE);

// Arm TDA
status = MMWL_ArmingTDA(tdaCfg);
check(status,
Expand Down Expand Up @@ -693,5 +732,11 @@ int main (int argc, char *argv[]) {
"[MMWCAS-RF] Failed to de-arm TDA board!\n", 32, TRUE);
msleep(1000);
}

// Disconnect from TDA
status = MMWL_TDADeInit();
check(status,
"[MMWCAS-DSP] TDA successfully disconnected!",
"[MMWCAS-DSP] Couldn't disconnect from TDA board!\n", 32, TRUE);
return 0;
}
2 changes: 1 addition & 1 deletion mimo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define PROG_NAME "mmwave" // Name of the program
#define PROG_VERSION "0.1" // Program version
#define PROG_COPYRIGHT "Copyright (C) 2022"
#define PROG_COPYRIGHT "Copyright (C) 2022 - 2023"

/* Enable development environment
Status messages are printed. Set to '0' to disable the
Expand Down
Loading