2021-03-23 22:31:27 +00:00
|
|
|
/*
|
|
|
|
* adb.h
|
|
|
|
* quack
|
|
|
|
*
|
|
|
|
* Created by Michel DEPEIGE on 7/01/2021.
|
|
|
|
* Copyright (c) 2020 Michel DEPEIGE.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2021-08-18 21:13:40 +00:00
|
|
|
* it under the terms of the Apache License, Version 2.0 (the "License");
|
|
|
|
* You may obtain a copy of the License at:
|
2021-03-23 22:31:27 +00:00
|
|
|
*
|
2021-08-18 21:13:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2021-03-23 22:31:27 +00:00
|
|
|
*
|
2021-08-18 21:13:40 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2021-03-23 22:31:27 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ADB_H
|
|
|
|
#define ADB_H
|
|
|
|
|
|
|
|
/* prototypes */
|
|
|
|
void adb_init(void);
|
2021-08-17 19:50:04 +00:00
|
|
|
bool adb_is_host(void);
|
2021-03-23 22:31:27 +00:00
|
|
|
void adb_task_host(void *pvParameters);
|
2021-08-11 18:42:44 +00:00
|
|
|
void adb_task_idle(void *pvParameters);
|
2021-03-23 22:31:27 +00:00
|
|
|
|
|
|
|
void adb_tx_cmd(unsigned char cmd);
|
2021-05-09 18:45:22 +00:00
|
|
|
void adb_tx_data(uint16_t data);
|
|
|
|
void adb_tx_listen(unsigned char cmd, uint16_t data);
|
2021-03-23 22:31:27 +00:00
|
|
|
void adb_tx_reset(void);
|
|
|
|
|
|
|
|
/* defines */
|
2021-04-01 18:58:23 +00:00
|
|
|
#define RMT_RX_CHANNEL RMT_CHANNEL_0
|
2021-03-24 09:26:20 +00:00
|
|
|
#define tskADB_PRIORITY 4
|
2021-03-23 22:31:27 +00:00
|
|
|
|
2021-04-01 18:58:23 +00:00
|
|
|
/* ADB timers */
|
|
|
|
#define ADB_RESET 3000
|
|
|
|
#define ADB_0_LOW 65
|
|
|
|
#define ADB_0_HIGH 35
|
|
|
|
#define ADB_1_LOW 35
|
|
|
|
#define ADB_1_HIGH 65
|
|
|
|
|
2021-05-03 22:45:23 +00:00
|
|
|
/* Classic Apple Mouse Protocol bitmasks */
|
|
|
|
#define ADB_CMP_B1 (1<<15)
|
|
|
|
#define ADB_CMP_B2 (1<<7)
|
2021-05-09 18:45:22 +00:00
|
|
|
#define ADB_CMP_MX (127<<0)
|
|
|
|
#define ADB_CMP_MY (127<<8)
|
2021-05-03 22:45:23 +00:00
|
|
|
|
2021-03-23 22:31:27 +00:00
|
|
|
/* ADB commands values from 00591b.pdf page 16-17 */
|
|
|
|
#define ADB_TALK 0xC
|
|
|
|
#define ADB_LISTEN 0x8
|
2021-05-09 18:45:22 +00:00
|
|
|
#define ADB_FLUSH 0x1
|
2021-03-23 22:31:27 +00:00
|
|
|
#define ADB_REG0 0x0
|
2021-04-01 18:58:23 +00:00
|
|
|
#define ADB_REG3 0x3
|
2021-03-23 22:31:27 +00:00
|
|
|
|
2021-05-09 18:45:22 +00:00
|
|
|
/* Device addresses */
|
|
|
|
#define ADB_MOUSE (3<<4)
|
2024-06-04 08:04:47 +00:00
|
|
|
#define ADB_KML1 (8<<4) // disabled Kensington device
|
|
|
|
#define ADB_TMP (9<<4)
|
2021-05-09 18:45:22 +00:00
|
|
|
|
2021-05-03 22:45:23 +00:00
|
|
|
/* Various stuff */
|
|
|
|
#define ADB_B_UP 0
|
|
|
|
#define ADB_B_DOWN 1
|
|
|
|
|
2021-05-09 18:45:22 +00:00
|
|
|
#define ADB_H_ALL 0xff // Handlers bitmask
|
2021-10-30 13:06:51 +00:00
|
|
|
#define ADB_H_ERR 0x00 // Handler 0 (Self init error)
|
2021-05-09 18:45:22 +00:00
|
|
|
#define ADB_H_C100 0x01 // Handler 1 (Classic @ 100cpi)
|
|
|
|
#define ADB_H_C200 0x02 // Handler 2 (Classic @ 200cpi)
|
2021-10-30 13:06:51 +00:00
|
|
|
#define ADB_H_MTRC 0x2f // Handler for MacTRAC 2.0
|
2024-06-04 08:04:47 +00:00
|
|
|
#define ADB_H_KSGT 0x32 // Handler for Kensington devices
|
2021-05-09 18:45:22 +00:00
|
|
|
#define ADB_H_MOVE 0xfe // Move to another address
|
|
|
|
|
|
|
|
/* Host states */
|
|
|
|
#define ADB_S_PROBE 0x00
|
|
|
|
#define ADM_S_POLL 0x01
|
|
|
|
#define ADB_S_KEEP 0x08
|
|
|
|
|
2021-03-23 22:31:27 +00:00
|
|
|
#endif
|