blob: c812cdf84894b4833aa447849bc7aa91a81017d5 [file] [log] [blame]
/*
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*/
#ifndef SW_DEVICE_LIB_SPI_DISPLAY_SPI_DISPLAY_H_
#define SW_DEVICE_LIB_SPI_DISPLAY_SPI_DISPLAY_H_
#include "sw/device/lib/dif/dif_rv_plic.h"
#include "sw/device/lib/dif/dif_spi_host.h"
#include "sw/device/lib/dif/dif_tlul_mailbox.h"
#include "sw/device/lib/testing/test_framework/check.h"
typedef struct spi_display {
dif_spi_host_t* spi_host;
dif_tlul_mailbox_t* mailbox;
bool spi_idle_seen;
bool gpio_write_done;
} spi_display_t;
#if defined(__cplusplus)
extern "C" {
#endif
dif_result_t spi_display_init(spi_display_t* spi_display,
dif_spi_host_t* spi_host,
dif_tlul_mailbox_t* mailbox);
dif_result_t spi_display_irq_init(spi_display_t* spi_display,
const dif_rv_plic_t* plic,
dif_rv_plic_irq_id_t irq_id,
dif_rv_plic_target_t target);
dif_result_t spi_display_spi_irq_handler(spi_display_t* spi_display);
dif_result_t spi_display_smc_mailbox_irq_handler(spi_display_t* spi_display);
void spi_display_block_write(spi_display_t* spi_display, const uint8_t* buffer,
size_t bytes);
void spi_display_byte_write(spi_display_t* spi_display, uint8_t value);
void spi_display_gpio_write(spi_display_t* spi_display, uint16_t pin,
uint8_t value);
#if defined(__cplusplus)
}
#endif
#endif // SW_DEVICE_LIB_SPI_DISPLAY_SPI_DISPLAY_H_
// init that takes spi_host_t
// interrupt handlers for both cores