tsys01/STM32/TSYS_controller/can_process.h

46 lines
1.6 KiB
C

/*
* geany_encoding=koi8-r
* can_process.h
*
* Copyright 2018 Edward V. Emelianov <eddy@sao.ru, edward.emelianoff@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#include "can.h"
// timeout for trying to send data
#define SEND_TIMEOUT_MS (10)
// mark first byte if command sent
#define COMMAND_MARK (0xA5)
// mark first byte if data sent
#define DATA_MARK (0x5A)
// 8-bit commands sent by master
typedef enum{
CMD_PING, // request for PONG cmd
CMD_START_MEASUREMENT, // start thermal measurement
CMD_SENSORS_STATE, // reply data with sensors state
// dummy commands for test purposes
CMD_DUMMY0 = 0xDA,
CMD_DUMMY1 = 0xAD
} CAN_commands;
void can_messages_proc();
CAN_status can_send_cmd(uint16_t targetID, uint8_t cmd);
CAN_status can_send_data(uint8_t *data, uint8_t len);
int8_t send_temperatures(int8_t N);