Skip to content

Commit

Permalink
Refactor Logic Analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
bessman committed Mar 10, 2024
1 parent ccccef3 commit 33448ed
Show file tree
Hide file tree
Showing 9 changed files with 429 additions and 433 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_TOOLCHAIN_FILE external/cmake-microchip/toolchain.cmake)
set(MICROCHIP_MCU PIC24EP256GP204)
set(CMAKE_SYSTEM_NAME Generic)

project(PSLAB_FIRMWARE LANGUAGES C ASM)

Expand Down
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ add_subdirectory(bus)
add_subdirectory(helpers)
add_subdirectory(instruments)
add_subdirectory(registers)
add_subdirectory(registers_ng)
add_subdirectory(sdcard)

target_sources(pslab-firmware.elf PRIVATE
commands.c
main.c
states.c)

target_include_directories(pslab-firmware.elf PRIVATE
$(CMAKE_CURRENT_SOURCE_DIR)
registers_ng
helpers
)
14 changes: 7 additions & 7 deletions src/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "helpers/interval.h"
#include "helpers/light.h"
#include "helpers/rtc.h"
#include "instruments/logicanalyzer.h"
#include "instruments/logic_analyzer.h"
#include "instruments/multimeter.h"
#include "instruments/oscilloscope.h"
#include "instruments/powersource.h"
Expand Down Expand Up @@ -217,7 +217,7 @@ command_func_t* const cmd_table[NUM_PRIMARY_CMDS + 1][NUM_SECONDARY_CMDS_MAX + 1
},
{ // 9 DIN
// 0 1 GET_STATE 2 GET_STATES 3
Undefined, Unimplemented, PIN_MANAGER_GetLAPinState, Undefined,
Undefined, Unimplemented, LA_get_states, Undefined,
// 4 5 6 7
Undefined, Undefined, Undefined, Undefined,
// 8 9 10 11
Expand All @@ -235,13 +235,13 @@ command_func_t* const cmd_table[NUM_PRIMARY_CMDS + 1][NUM_SECONDARY_CMDS_MAX + 1
// 0 1 GET_TIMING 2 3
Undefined, Unimplemented, Undefined, Undefined,
// 4 START_ONE_CHAN_LA 5 START_TWO_CHAN_LA 6 START_FOUR_CHAN_LA 7 FETCH_DMA_DATA
LOGICANALYZER_OneChannel, LOGICANALYZER_TwoChannel, LOGICANALYZER_FourChannel, Removed,
LA_capture, Removed, Removed, Removed,
// 8 FETCH_INT_DMA_DATA 9 FETCH_LONG_DMA_DATA 10 COMPARATOR_TO_LA 11 GET_INITIAL_STATES
BUFFER_FetchInt, BUFFER_FetchLong, Unimplemented, INTERVAL_GetState,
BUFFER_FetchInt, BUFFER_FetchLong, Unimplemented, LA_get_initial_states,
// 12 TIMING_MEASUREMENTS 13 INTERVAL_MEASUREMENTS 14 CONFIGURE_COMPARATOR 15 START_ALTERNATE_ONE_CHAN_LA
Unimplemented, Unimplemented, Removed, LOGICANALYZER_OneChannelAlt,
Unimplemented, Unimplemented, Removed, Removed,
// 16 START_THREE_CHAN_LA 17 STOP_LA 18 19
LOGICANALYZER_ThreeChannel, LOGICANALYZER_Stop, Undefined, Undefined,
Removed, LA_stop, Undefined, Undefined,
// 20 21 22 23
Undefined, Undefined, Undefined, Undefined,
// 24 25 26 27
Expand Down Expand Up @@ -310,5 +310,5 @@ command_func_t* const cmd_table[NUM_PRIMARY_CMDS + 1][NUM_SECONDARY_CMDS_MAX + 1
Undefined, Undefined, Undefined, Undefined,
// 24 25 26 27
Undefined, Undefined, Undefined, Undefined,
},
},
};
32 changes: 17 additions & 15 deletions src/helpers/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,86 @@

#include <stdint.h>

#include "commands.h"

#define BUFFER_SIZE 10000

#ifdef __cplusplus
extern "C" {
#endif

extern uint16_t volatile __attribute__((section(".adc_buffer"), far)) BUFFER[BUFFER_SIZE];

/**
* @brief Send buffer contents.
*
*
* @description
* This command function takes two arguments over serial:
* 1. The starting index in the buffer from which to send values.
* 2. The number of values to be sent.
* It returns the requested data over serial.
* It sends an acknowledge byte (SUCCESS)
*
*
* @return SUCCESS
*/
response_t BUFFER_Retrieve(void);

/**
* @brief Send buffer content as integers.
*
*
* @description
* This command function takes two arguments over serial:
* 1. The starting index in the buffer from which to send values.
* 2. The number of values to be sent.
*
* It returns the requested data over serial.
* It sends an acknowledge byte (SUCCESS)
*
*
* @return SUCCESS
*/
response_t BUFFER_FetchInt(void);

/**
* @brief Send buffer content as longs.
*
*
* @description
* This command function takes two arguments over serial:
* 1. The starting index in the buffer from which to send values.
* 2. The number of values to be sent.
*
* It returns the requested data over serial.
* It sends an acknowledge byte (SUCCESS)
*
*
* @return SUCCESS
*/
response_t BUFFER_FetchLong(void);

/**
* @brief Populate BUFFER array
*
*
* @description
* This command function takes two arguments over serial:
* 1. The starting index in the buffer from which to fill values.
* 2. The number of values to be sent.
*
*
* It does not return anything over serial.
* It sends an acknowledge byte (SUCCESS)
*
*
* @return SUCCESS
*/
response_t BUFFER_Fill(void);

/**
* @brief Clear BUFFER array
*
*
* @description
* This command function takes two arguments over serial:
* 1. The starting index in the buffer from which it should be emptied
* 2. The number of indices need cleared.
*
* It does not return anything over serial.
* It sends an acknowledge byte (SUCCESS)
*
*
* @return SUCCESS
*/
response_t BUFFER_Clear(void);
Expand Down
5 changes: 2 additions & 3 deletions src/instruments/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
target_sources(pslab-firmware.elf PRIVATE
logicanalyzer.c
logic_analyzer.c
multimeter.c
oscilloscope.c
powersource.c
Expand All @@ -8,5 +8,4 @@ target_sources(pslab-firmware.elf PRIVATE
)

target_include_directories(pslab-firmware.elf
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
Loading

0 comments on commit 33448ed

Please sign in to comment.