Initial commit: MT firmware project

- BLE peripheral applications
- dr_piezo and bladder_patch projects

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Charles Kwon
2026-01-25 17:26:39 +09:00
commit a8ba31871e
2561 changed files with 1594625 additions and 0 deletions

View File

@@ -0,0 +1,158 @@
#include "sdk_common.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "nrf.h"
#include "nrf_drv_gpiote.h"
#include "nrf_drv_spi.h"
#include "nrf_drv_saadc.h"
#include "nrf_drv_ppi.h"
#include "nrf_drv_timer.h"
#include "boards.h"
#include "nrf_log.h"
#include "LED_Parse.h"
#include "app_timer.h"
#include "measurements.h"
#include "main.h"
//#include "fstorage.h"
#include "mcp4725_i2c.h" //VGA
#include "ir_i2c.h" //IR
#include "debug_print.h"
//#define LED_S1 0x50 //VGA LED1~5
//#define LED_S2 0x50
//#define LED_S3 0x51
//#define LED_S4 0x52
//#define LED_S5 0x53
//#define LED_S6 0x51 //VGA
//#define LED_S7 0x54
//#define LED_S8 0x55
//#define LED_S9 0x56
//#define LED_S10 0x57 //LED 46~50
#define LED_S0 0x50
#define LED_S1 0x51
#define LED_S2 0x52
#define LED_S3 0x53
#define LED_S4 0x54
#define LED_S5 0x55
#define LED_S6 0x56
#define LED_S7 0x57
uint8_t LED_READ_ROM(uint8_t led_index)
{
// uint32_t err_code = NRF_SUCCESS;
uint8_t addr=0xf0;
uint8_t r_index;
r_index = (led_index)%6;
uint8_t r_data[10];
uint8_t r_value=0;
switch(led_index) {
case 0: case 1: case 2: case 3: case 4: case 5:
r_value = ir_command_read(LED_S0, addr + r_index, r_data);
break;
case 6: case 7: case 8: case 9: case 10: case 11:
r_value = ir_command_read(LED_S1, addr + r_index, r_data);
break;
case 12: case 13: case 14: case 15: case 16: case 17:
r_value = ir_command_read(LED_S2, addr + r_index, r_data);
break;
case 18: case 19: case 20: case 21: case 22: case 23:
r_value = ir_command_read(LED_S3, addr + r_index, r_data);
break;
case 24: case 25: case 26: case 27: case 28: case 29:
r_value = ir_command_read(LED_S4, addr + r_index, r_data);
break;
case 30: case 31: case 32: case 33: case 34: case 35:
r_value = ir_command_read(LED_S5, addr + r_index, r_data);
break;
case 36: case 37: case 38: case 39: case 40: case 41:
r_value = ir_command_read(LED_S6, addr + r_index, r_data);
break;
case 42: case 43: case 44: case 45: case 46: case 47:
r_value = ir_command_read(LED_S7, addr + r_index, r_data);
break;
default:
DBG_PRINTF("Invalid LED index\r\n");
// err_code = NRF_ERROR_NOT_FOUND;
break;
}
return r_value;
}
ret_code_t LED_WRITE_ROM(uint8_t led_index, int16_t led_power)
{
uint32_t err_code = NRF_SUCCESS;
uint8_t addr=0xf0;
uint8_t r_index;
r_index = (led_index)%6;
switch(led_index) {
case 0: case 1: case 2: case 3: case 4: case 5:
ir_command_write(LED_S0, addr + r_index, led_power);
break;
case 6: case 7: case 8: case 9: case 10: case 11:
ir_command_write(LED_S1, addr + r_index, led_power);
break;
case 12: case 13: case 14: case 15: case 16: case 17:
ir_command_write(LED_S2, addr + r_index, led_power);
break;
case 18: case 19: case 20: case 21: case 22: case 23:
ir_command_write(LED_S3, addr + r_index, led_power);
break;
case 24: case 25: case 26: case 27: case 28: case 29:
ir_command_write(LED_S4, addr + r_index, led_power);
break;
case 30: case 31: case 32: case 33: case 34: case 35:
ir_command_write(LED_S5, addr + r_index, led_power);
break;
case 36: case 37: case 38: case 39: case 40: case 41:
ir_command_write(LED_S6, addr + r_index, led_power);
break;
case 42: case 43: case 44: case 45: case 46: case 47:
ir_command_write(LED_S7, addr + r_index, led_power);
break;
default:
DBG_PRINTF("Invalid LED index\r\n");
err_code = NRF_ERROR_NOT_FOUND;
break;
}
DBG_PRINTF("write\r\n");
return err_code;
}