aboutsummaryrefslogtreecommitdiffstats
path: root/usr/space_light/src/diagnostic.c
blob: d1afb25e7d970cea75badb9ade4e6d5f579d4026 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "generic.h"

#include "RomCallFlash.h"
#include "ble_reg_access.h"
#include "common_hci.h"
#include "common_llcp.h"
#include "common_utils.h"
#include "ea.h"
#include "ecc_p256.h"
#include "em_buf.h"
#include "em_map_ble.h"
#include "lld.h"
#include "lld_evt.h"
#include "lld_pdu.h"
#include "lld_util.h"
#include "llm.h"
#include "llm_util.h"
#include "reg_ble_em_cs.h"
#include "reg_ble_em_rx_buffer.h"
#include "reg_ble_em_rx_desc.h"
#include "reg_ble_em_tx_buffer_cntl.h"
#include "reg_ble_em_tx_buffer_data.h"
#include "reg_ble_em_tx_desc.h"
#include "reg_blecore.h"
#include "rwip.h"
#include "rwip_config.h"

void output_ble_registers(void);

uint32_t assembly_test0(uint32_t input);

void output_ble_registers(void) {

  uint8_t rxpwrup0 = 0;
  uint8_t txpwrdn0 = 0;
  uint8_t txpwrup0 = 0;

  bk_printf("BLE control[8]: 0x%x\n", ble_cntl_get(8));

  ble_radiopwrupdn0_unpack(&rxpwrup0, &txpwrdn0, &txpwrup0);
  bk_printf(
      "Power down control 0: rxpwrup0::0x%x, txpwrdn0::0x%x, txpwrup0::0x%x\n",
      rxpwrup0, txpwrdn0, txpwrup0);
  bk_printf("Power down control 0: 0x%x\n", ble_radiopwrupdn0_get());
  bk_printf("Interrupt control: 0x%x\n", ble_intcntl_get());
  bk_printf("Upper BDADDR: 0x%x\n", ble_bdaddru_getf());
  bk_printf("Lower BDADDR: 0x%x\n", ble_bdaddrl_getf());
}

uint32_t assembly_test0(uint32_t input) {
  uint32_t output = 0xABCDEFEF;
  __asm__ __volatile__("        sub r3, %0, #1\n"
                       "        sbc %0, r3\n"
                       : "=r"(output)
                       : "0"(input)
                       : "cc", "r3");
  return output;
}

void output_diagnostics(void) {

  output_ble_registers();

  bk_printf("Assembly test 0, input=0, output=0x%x\n", assembly_test0(0));
  bk_printf("Assembly test 0, input=0x800, output=0x%x\n",
            assembly_test0(0x800));
}