diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-06-20 11:40:13 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-06-20 11:40:13 +0200 |
| commit | ced21c69f7b399dce169069334c1424e5254d582 (patch) | |
| tree | f8d7f3bb4eed04410881334992f664e6e0edcb64 /examples/io | |
| parent | eaea5649a0803cc4bfeb6d21ee9f4098d4b493fc (diff) | |
| download | psn00bsdk-ced21c69f7b399dce169069334c1424e5254d582.tar.gz | |
Update io/pads and sound/cdstream examples
Diffstat (limited to 'examples/io')
| -rw-r--r-- | examples/io/pads/spi.c | 23 | ||||
| -rw-r--r-- | examples/io/pads/spi.h | 33 |
2 files changed, 29 insertions, 27 deletions
diff --git a/examples/io/pads/spi.c b/examples/io/pads/spi.c index 234bdba..839f811 100644 --- a/examples/io/pads/spi.c +++ b/examples/io/pads/spi.c @@ -1,29 +1,6 @@ /* * PSn00bSDK controller polling example (SPI driver) * (C) 2021 spicyjpeg - MPL licensed - * - * This is a fairly complete timer driven, asynchronous high-speed SPI driver, - * with support for sending custom commands (including memory card access), in - * about 200 lines of code. Feel free to copypaste and adapt it. - * - * The way this works is by maintaining a queue of requests to send, each with - * its own payload and callback. Timer 2 is configured to trigger an IRQ at - * regular intervals. On each tick, the next request in the queue (or a poll - * command if no request is pending) is prepared and the first byte is - * sent; if the controller asks for more data by pulling /ACK low, the next - * byte is sent and the received byte is placed into a buffer. This goes on - * until the last byte is exchanged and the controller stops asserting /ACK. - * - * On the next tick, the response buffer is passed to the request's callback - * and reset, and the next request in the queue is sent. This blindly assumes - * it only takes one tick for a request/response to be sent, which is the case - * for controllers' very small packets but not for memory cards. It is - * advisable to call spi_set_poll_rate() to temporarily reduce poll rate while - * accessing memory cards. - * - * Note that this driver completely takes over the SPI bus, so you won't be - * able to use any BIOS functions that rely on SPI access (i.e. pad and memory - * card APIs) alongside it. */ #include <stdint.h> diff --git a/examples/io/pads/spi.h b/examples/io/pads/spi.h index 8c17df3..72a2f99 100644 --- a/examples/io/pads/spi.h +++ b/examples/io/pads/spi.h @@ -3,8 +3,35 @@ * (C) 2021 spicyjpeg - MPL licensed */ -#ifndef __SPI_H -#define __SPI_H +/** + * @file spi.h + * @brief Asynchronous SPI controller driver + * + * @details This is a fairly complete timer driven, asynchronous high-speed SPI + * driver, with support for sending custom commands (including memory card + * access), in about 200 lines of code. Feel free to copy and adapt it. + * + * The way this works is by maintaining a queue of requests to send, each with + * its own payload and callback. Timer 2 is configured to trigger an IRQ at + * regular intervals. On each tick, the next request in the queue (or a poll + * command if no request is pending) is prepared and the first byte is + * sent; if the controller asks for more data by pulling /ACK low, the next + * byte is sent and the received byte is placed into a buffer. This goes on + * until the last byte is exchanged and the controller stops asserting /ACK. + * + * On the next tick, the response buffer is passed to the request's callback + * and reset, and the next request in the queue is sent. This blindly assumes + * it only takes one tick for a request/response to be sent, which is the case + * for controllers' very small packets but not for memory cards. It is + * advisable to call spi_set_poll_rate() to temporarily reduce poll rate while + * accessing memory cards. + * + * Note that this driver completely takes over the SPI bus, so you won't be + * able to use any BIOS functions that rely on SPI access (i.e. pad and memory + * card APIs) alongside it. + */ + +#pragma once #include <stdint.h> #include <stddef.h> @@ -68,5 +95,3 @@ void SPI_Init(SPI_Callback callback); #ifdef __cplusplus } #endif - -#endif |
