Skip to content

Commit

Permalink
Update how monitoring code is generated and data stored (#221)
Browse files Browse the repository at this point in the history
* Use yaml file to drive generation of arrays to store MonI2C registers
* use py script to write code for storage based on yaml file 
* transition to  slightly rewritten i2c mon task; one per I2C controller on the MCU

Other fixes
* start breaking up LocalTasks.c and move firefly related to FireflyUtils
* adapt getopt, add getopt_dev and byteswap as needed
* new 3.3V FF command, ff cdr enable and ff tx enable cli commands
* set i2c comms with FF to 400 kHz from 100 kHz
  • Loading branch information
pwittich authored Jun 12, 2024
1 parent 864ea11 commit 049babb
Show file tree
Hide file tree
Showing 40 changed files with 2,172 additions and 1,659 deletions.
7 changes: 4 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ Checks: -*,
,readability-uniqueptr-delete-release,
,security*
,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
,readability-braces-around-statements
,readability-*
WarningsAsErrors: ''
AnalyzeTemporaryDtors: false
HeaderFilterRegex: .*FreeRTOS.*/.*
CheckOptions:
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: readability-braces-around-statements.ShortStatementLines
value: '5'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
Expand All @@ -46,4 +48,3 @@ CheckOptions:
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
...

6 changes: 6 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Diagnostics:
ClangTidy:
Add: modernize*
Remove: readability-braces-around-statements
#CompileFlags:
#Add: [-Wunused-parameter]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ projects/cm_mcu/ZynqMon_addresses.c
projects/cm_mcu/ZynqMon_addresses.h
PL_MEM_CM_rev1.xml
PL_MEM_CM_rev2.xml
projects/cm_mcu/MonI2C_addresses.c
projects/cm_mcu/MonI2C_addresses.h
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@ check-and-reinit-submodules:
release:
@$(MAKE) -C projects/cm_mcu release

check-for-pr: format
@./buildall.sh


# 2nd dollar sign in grep command is to pass along a single dollar sign to egrep itself
format:
run-clang-format.py $(shell git diff --diff-filter=AM --name-only master | egrep '\.[ch]$$')

format-apply:
run-clang-format.py -i $(shell git diff --diff-filter=AM --name-only master | egrep '\.[ch]$$')

.PHONY: all clean $(DIRS) $(DIRSCLEAN) check-and-reinit-submodules
1 change: 1 addition & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ make COMPILER=clang clean
make -j REV1=1 COMPILER=clang > /dev/null
make COMPILER=clang clean
make -j REV2=1 COMPILER=clang > /dev/null
make format > /dev/null
echo "all build succeeded."

4 changes: 2 additions & 2 deletions common/i2c_reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void initI2C3(const uint32_t sysclockfreq)
// the I2C3 module. The last parameter sets the I2C data transfer rate.
// If false the data rate is set to 100kbps and if true the data rate will
// be set to 400kbps.
MAP_I2CMasterInitExpClk(I2C3_BASE, sysclockfreq, false);
MAP_I2CMasterInitExpClk(I2C3_BASE, sysclockfreq, true);
while (!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_I2C3))
;

Expand Down Expand Up @@ -212,7 +212,7 @@ void initI2C4(const uint32_t sysclockfreq)
// the I2C4 module. The last parameter sets the I2C data transfer rate.
// If false the data rate is set to 100kbps and if true the data rate will
// be set to 400kbps.
MAP_I2CMasterInitExpClk(I2C4_BASE, sysclockfreq, false);
MAP_I2CMasterInitExpClk(I2C4_BASE, sysclockfreq, true);
while (!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_I2C4))
;

Expand Down
9 changes: 2 additions & 7 deletions common/power_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
* Author: wittich
*/

#include <string.h>

#include "common/power_ctl.h"
#include "common/pinsel.h"
#include "common/utils.h"

#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"

#ifdef USE_FREERTOS
#include "FreeRTOS.h"
#include "FreeRTOS.h" // IWYU pragma: keep
#include "task.h"
#endif // USE_FREERTOS

Expand Down Expand Up @@ -73,7 +68,7 @@ struct gpio_pin_t oks[] = {
//
// ------------------------------------------
// if you update this you need to update N_PS_ENABLES
static const struct gpio_pin_t enables[] = {
static const struct gpio_pin_t enables[N_PS_ENABLES] = {
{ EN_F1_INT, "EN_F1_INT", 1},
{ EN_F2_INT, "EN_F2_INT", 1},
{ EN_1V8, "EN_1V8", 2},
Expand Down
6 changes: 3 additions & 3 deletions common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* Created on: May 9, 2019
* Author: wittich
*/
#include <stdint.h>
#include <stddef.h>

#include "common/utils.h"
#include "common/pinsel.h"
#include "common/printf.h"
#include "driverlib/gpio.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/debug.h"
#include "driverlib/eeprom.h"
#include "FreeRTOS.h"
#include "FreeRTOS.h" // IWYU pragma: keep
#include "Tasks.h"

typedef struct error_buffer_t error_buffer_t;
Expand Down
6 changes: 3 additions & 3 deletions common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <stdbool.h>
#include <sys/_types.h>

#include "math.h"
#include "stdlib.h"
#include <math.h> // IWYU pragma: keep (for fmaxf, fmax, fmaxl)
#include <stdlib.h> // IWYU pragma: keep (for abs, labs, llabs, fabs, fabsf)

// write, read or toggle GPIO pin by name
void write_gpio_pin(int pin, uint8_t value);
Expand Down Expand Up @@ -127,7 +127,7 @@ bool checkStale(unsigned oldTime, unsigned newTime);

void float_to_ints(float val, int *tens, int *fraction);
// this will suffer from the double evaluation bug
//#define MAX(a,b) (a)>(b)?(a):(b)
// #define MAX(a,b) (a)>(b)?(a):(b)
// instead use these functions and a _generic macro
// this is overkill, but I'm parking it here because I never remember this exists.
inline int max(int const x, int const y)
Expand Down
1 change: 1 addition & 0 deletions projects/cm_mcu/AlarmUtilities.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "AlarmUtilities.h"
#include "Tasks.h"
#include "MonitorTask.h"
#include "FireflyUtils.h"

#include "common/log.h"
#include "common/pinsel.h"
Expand Down
36 changes: 33 additions & 3 deletions projects/cm_mcu/CommandLineTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,53 @@ static struct command_t commands[] = {
0,
},
#ifdef REV2
{
"ff_cdr_ena",
ff_cdr_enable_status,
"Show FF CDR enable status\r\n",
0,
},
{
"ff_ch_dis",
ff_ch_disable_status,
"Show FF ch disable status\r\n",
0,
},
{
"ff_mux_reset",
ff_mux_reset,
"reset ff muxes, 1 or 2 for F1 or F2\r\n",
1,
},
#endif // REV2
{
"ff_dump_names",
ff_dump_names,
"dump name registers\r\n",
0,
},
{
"ff_optpow",
ff_optpow,
"Showing the FF per-ch optical power \r\n",
"Show avg FF optical power\r\n",
0,
},
{
"ff_optpow_dev",
ff_optpow_dev,
"Show dev FF optical power\r\n",
1,
},
{
"ff_volts",
ff_v3v3,
"Show FF 3v3 mon\r\n",
0,
},
#endif // REV2
{
"ff_temp",
ff_temp,
"Showing FF temperatures\r\n",
"Show FF temperatures\r\n",
0,
},
{"fpga", fpga_ctl, "Show state of FPGAs\r\n",
Expand Down
Loading

0 comments on commit 049babb

Please sign in to comment.