-
Notifications
You must be signed in to change notification settings - Fork 3
/
swarm.c
60 lines (53 loc) · 1.29 KB
/
swarm.c
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
/*
* Copyright (C) 2023 ETH Zurich
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the GPL-3.0 license. See the LICENSE file for details.
*
* Author: Carl Friess
*/
#include "swarm.h"
#include "cfassert.h"
#include "debug.h"
#include "swarm_radio.h"
uint8_t swarm_id;
// Static ID map
static const struct {
uint32_t mcu_id;
uint8_t swarm_id;
} id_map[SWARM_NUM_DEVICES] = {
{
.mcu_id = 0x00240035,
.swarm_id = 0,
},
// {
// .mcu_id = 0x003A0032,
// .swarm_id = 1,
// },
// {
// .mcu_id = 0x0026001D,
// .swarm_id = 2,
// },
// {
// .mcu_id = 0x0044001B,
// .swarm_id = 3,
// },
// Bridge (base station)
{
.mcu_id = 0x0027004D,
.swarm_id = RADIO_ADR_BRIDGE,
},
};
void swarm_init() {
// Set swarm address of this drone
swarm_id = 0xFF;
for (int i = 0; i < SWARM_NUM_DEVICES; i++) {
if (*((uint32_t *) (MCU_ID_ADDRESS)) == id_map[i].mcu_id) {
swarm_id = id_map[i].swarm_id;
break;
}
}
ASSERT(swarm_id != 0xFF);
DEBUG_PRINT("SWARM ADDR: %d\n", swarm_id);
}