sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
send_mc.h
1/*
2 * Copyright (c) 2021 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef __SEND_MC_H__
17#define __SEND_MC_H__
18
19#include <stdint.h>
20#include <spin1_api.h>
21#include <spin1_api_params.h>
22#include <debug.h>
23
25#define TX_NOT_FULL_MASK 0x10000000
26
29static inline void wait_for_cc(void) {
30 uint32_t n_loops = 0;
31 while (!(cc[CC_TCR] & TX_NOT_FULL_MASK) && (n_loops < 10000)) {
32 spin1_delay_us(1);
33 n_loops++;
34 }
35 if (!(cc[CC_TCR] & TX_NOT_FULL_MASK)) {
36 log_error("Couldn't send spike; TCR=0x%08x\n", cc[CC_TCR]);
37 rt_error(RTE_SWERR);
38 }
39}
40
43static inline void send_spike_mc(uint32_t key) {
44 wait_for_cc();
45 cc[CC_TCR] = PKT_MC;
46 cc[CC_TXKEY] = key;
47}
48
51static inline void send_spike_mc_payload(uint32_t key, uint32_t payload) {
52 wait_for_cc();
53 cc[CC_TCR] = PKT_MC;
54 cc[CC_TXDATA] = payload;
55 cc[CC_TXKEY] = key;
56}
57#endif // __SEND_MC_H__
void log_error(const char *message,...)
static uint32_t key
Base multicast key for sending messages.
void rt_error(uint code,...)
PKT_MC
#define CC_TCR
#define CC_TXDATA
#define CC_TXKEY