mirror of
https://github.com/eddyem/tsys01.git
synced 2025-12-06 18:45:15 +03:00
53 lines
2.0 KiB
C
53 lines
2.0 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
|
|
CMD_START_SCAN, // run scan mode @ all controllers
|
|
CMD_STOP_SCAN, // stop scan mode
|
|
CMD_SENSORS_OFF, // turn off power of sensors
|
|
CMD_LOWEST_SPEED, // lowest I2C speed
|
|
CMD_LOW_SPEED, // low I2C speed (10kHz)
|
|
CMD_HIGH_SPEED, // high I2C speed (100kHz)
|
|
CMD_REINIT_I2C, // reinit I2C with current speed
|
|
// 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);
|