/****************************************************************************/
/* Copyright 2012 MBARI.                                                    */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/\

#ifndef SLOT_H
#define SLOT_H

#include <p24fxxxx.h>

/** Number of slots on the backplane */
#define NUM_SLOTS 8

/** Number of clock ticks between cache updates */
extern int slotUpdateInterval;

/**
 * Detects the type of daughterboard in each slot, and stores it in card_types.
 * Lets us know what cards are available when parsing user commands.
 */
void slotInit();

/**
 * Sets the slot SPI1 is to communicate with.  Call this prior to any
 * communications over SPI1.
 * @param slot the slot number of the target daughterboard
 */
void slotSet(unsigned char slot);

void slotSelect(unsigned char slot);
void slotDeselect();

/** Returns the daughterboard type of the given slot on the backplane.
 *  @param slot the port on the backplane to check
 *  @return the daugherboard type of the given slot: a number in the range
 *  [0:9]
 */
unsigned char slotGetType(unsigned char slot);

const char* slotGetName(unsigned char slot);

unsigned char slotTypeFromName(const char* name);

/**
 * Returns string name of a card type number.
 * @param type daughtercard type number
 * @return the string name of the given type, or NULL if the given type is
 * invalid
 */
const char* slotDisplayName(unsigned char type);

void slotDumpInfo(unsigned char slot);

void slotUpdate();

#endif
