-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZuluSCSI_platform.h
106 lines (83 loc) · 3.17 KB
/
ZuluSCSI_platform.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Platform-specific definitions for ZuluSCSI.
//
// This file is example platform definition that can easily be
// customized for a different board / CPU.
#pragma once
/* Add any platform-specific includes you need here */
#include <stdint.h>
#include <Arduino.h>
#include "ZuluSCSI_platform_gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
/* These are used in debug output and default SCSI strings */
extern const char *g_platform_name;
#define PLATFORM_NAME "Example"
#define PLATFORM_REVISION "1.0"
// Debug logging function, can be used to print to e.g. serial port.
// May get called from interrupt handlers.
void platform_log(const char *s);
// Timing and delay functions.
// Arduino platform already provides these
unsigned long millis(void);
void delay(unsigned long ms);
// Short delays, can be called from interrupt mode
static inline void delay_ns(unsigned long ns)
{
delayMicroseconds(ns / 1000);
}
// Approximate fast delay
static inline void delay_100ns()
{
asm volatile ("nop \n nop \n nop \n nop \n nop");
}
// Initialize SD card and GPIO configuration
void platform_init();
// Initialization for main application, not used for bootloader
void platform_late_init();
// Disable the status LED
void platform_disable_led(void);
// Setup soft watchdog if supported
void platform_reset_watchdog();
// Set callback that will be called during data transfer to/from SD card.
// This can be used to implement simultaneous transfer to SCSI bus.
typedef void (*sd_callback_t)(uint32_t bytes_complete);
void platform_set_sd_callback(sd_callback_t func, const uint8_t *buffer);
// Below are GPIO access definitions that are used from scsiPhy.cpp.
// The definitions shown will work for STM32 style devices, other platforms
// will need adaptations.
// Write a single SCSI pin.
// Example use: SCSI_OUT(ATN, 1) sets SCSI_ATN to low (active) state.
#define SCSI_OUT(pin, state) \
(SCSI_OUT_ ## pin ## _PORT)->BSRR = (SCSI_OUT_ ## pin ## _PIN) << (state ? 16 : 0)
// Read a single SCSI pin.
// Example use: SCSI_IN(ATN), returns 1 for active low state.
#define SCSI_IN(pin) \
(((SCSI_ ## pin ## _PORT)->IDR & (SCSI_ ## pin ## _PIN)) ? 0 : 1)
// Write SCSI data bus, also sets REQ to inactive.
extern const uint32_t g_scsi_out_byte_to_bop[256];
#define SCSI_OUT_DATA(data) \
(SCSI_OUT_PORT)->BSRR = g_scsi_out_byte_to_bop[(uint8_t)(data)]
// Release SCSI data bus and REQ signal
#define SCSI_RELEASE_DATA_REQ() \
(SCSI_OUT_PORT)->BSRR = SCSI_OUT_DATA_MASK | SCSI_OUT_REQ
// Release all SCSI outputs
#define SCSI_RELEASE_OUTPUTS() \
(SCSI_OUT_PORT)->BSRR = SCSI_OUT_DATA_MASK | SCSI_OUT_REQ, \
(SCSI_OUT_IO_PORT)->BSRR = SCSI_OUT_IO_PIN, \
(SCSI_OUT_CD_PORT)->BSRR = SCSI_OUT_CD_PIN, \
(SCSI_OUT_SEL_PORT)->BSRR = SCSI_OUT_SEL_PIN, \
(SCSI_OUT_MSG_PORT)->BSRR = SCSI_OUT_MSG_PIN, \
(SCSI_OUT_RST_PORT)->BSRR = SCSI_OUT_RST_PIN, \
(SCSI_OUT_BSY_PORT)->BSRR = SCSI_OUT_BSY_PIN
// Read SCSI data bus
#define SCSI_IN_DATA(data) \
(((~(SCSI_IN_PORT->IDR)) & SCSI_IN_MASK) >> SCSI_IN_SHIFT)
#ifdef __cplusplus
}
// SD card driver for SdFat
class SdSpiConfig;
extern SdSpiConfig g_sd_spi_config;
#define SD_CONFIG g_sd_spi_config
#define SD_CONFIG_CRASH g_sd_spi_config
#endif