Author | Stef Mientki, Copyright (c) 2002..2008, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4g |
library to use the PIC's AD converter See 16F87x datasheet (DS30292C, p112) Number of channels, behind "--" yields only for 16F874 and 16F877 No external Vref: Nchan = 1,3,5 -- 6,8 Only external +Vref: Nchan = 2,4 -- 5,7 Both external +Vref and - Vref: Nchan = 1,2,3 -- 4,6 Analog channels can still be used as digital outputs, by setting pin = output relevant IO pins * RA0 = AN0 * RA1 = AN1 * RA2 = AN2 or -Vref * RA3 = AN3 or +Vref * RA4 = no analog IO * RA5 = AN4 * next pins only for 16F874 and 16F877 * RE0 = AN5 * RE1 = AN6 * RE2 = AN7 Example PIC-AD (if you use JALcc, you can copy the complete example below and "uncomment" it) define the AD converter settings const ADC_hardware_Nchan = 2 ;number of selected channels const ADC_hardware_NVref = 0 ;number of external references const ADC_hardware_Rsource = 10_000 ;maximum source resistance const ADC_hardware_high_resolution = true ;true = high resolution = 10 bits ;false = low resolution = 8 bits get the library, after defining the constants include adc_hardware initialize the AD converter according to the above parameters ADC_init now take a sample read high resolution, channel 0 var_word=adc_read(0) read low resolution, channel 0 var_byte=adc_read_low_res(0)
I (Stef) mixed the following libraries with my own ideas * f877_modules.jal from Javier Martinez * janalog.jal from Vasile Surducan
_adc_read_low_res(byte in adc_chan, byte out adc_byte)
_adc_init_2_vref()
_adc_init_1_vref()
_adc_init_no_vref()
_ad_init_general()
var volatile byte _adc_acquisition_time
No documentation found
var volatile byte _adcon0_shadow = 0
No documentation found
adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out adc_lbyte)
Does an AD conversion on the selected channel returns the 10-bit result as 2 byte parameters It doesn't matter if ADC is set to low or high resolution
adc_on()
Turns all ADC channels back on
adc_init()
Initializes the PIC AD-converter, by calling the correct routine according to the number of external references Settings are done according to the special ADC constants Sets all the analog pins to input Calculates aquisition time and determines if right or left justification is optimal
_adc_read_low_res(byte in adc_chan, byte out adc_byte)
Does an AD conversion with low resolution (8 bit) on the selected channel
_adc_init_2_vref()
Initializes the PIC AD-converter, when both +Vref and -Vref are present Settings are done according to the special ADC constants Sets all the analog pins to input Calculates aquisition time and determines if right or left justification is optimal
_adc_init_1_vref()
Initializes the PIC AD-converter, when only +Vref is present Settings are done according to the special ADC constants Sets all the analog pins to input Calculates aquisition time and determines if right or left justification is optimal
_adc_init_no_vref()
Initializes the PIC AD-converter, when no external Vref is present Settings are done according to the special ADC constants Sets all the analog pins to input Calculates aquisition time and determines if right or left justification is optimal
_ad_init_general()
Internal routine, that calculates aquisition time and determines if right or left justification is optimal
adc_read(byte in adc_chan) return word
Does an AD conversion on the selected channel returns the result as a 10-bits word It doesn't matter if ADC is set to low or high resolution
adc_read_low_res(byte in adc_chan) return byte
Returns Low Resolution ADC-value as the RESULT It doesn't matter if ADC is set to low or high resolution
16f88 | 16f88_adc_lowres.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f4550 | 18f4550_usb_hid_generic.jal |
Author | Eur van Andel, Copyright (c) 2008, all rights reserved. |
Adapted-by | |
Compiler | >=2.4h |
This library has only one fuction: calendar(). It assumes the following variables: var volatile byte seconds (typically updated by an ISR) var byte hours, minutes, date, month var word year It knows the leap years until 2099.
No dependency found
calendar()
No documentation found
16f876a | 16f876a_rtc_lcd.jal |
16f877a | 16f877a_rtc_lcd.jal |
Author | Eur van Andel, eur@fiwihex.nl Copyright (c) 2008 |
Adapted-by | |
Compiler | =2.4h |
this library communicates with the T6603 GE/Telaire CO2 sensor. This sensor uses the Telaire Tsunami-Lite Commnications Protocol (no kidding), which is a definition with zero hits on Google. available functions are: get_status() return byte get_co2_ppm() return word -- CO2 concentration in ppm get_serial_numer() return string[15] get_elevation_m() return word -- in meters above sea level
The brochure is here: www.gesensing.com/downloads/datasheets/920-419A_LR.pdf Some clippings from the protocol document: ------------ START OF PROTOCOL DOCUMENT CLIPPINGS ---------------------
No dependency found
const ELEVATION = 0x0F
const SERIAL = 0x01
var word co2_global -- global CO2 value, keeps value when garbage reply
const FLAG = 0xFF
const CMD_READ = 0x02
const BRDCST = 0xFE
const CMD_UPDATE = 0x03
const CMD_STATUS = 0xB6
const CO2_PPM = 0x03
const ELEVATION = 0x0F
No documentation found
const SERIAL = 0x01
No documentation found
var word co2_global -- global CO2 value, keeps value when garbage reply
No documentation found
const FLAG = 0xFF
No documentation found
const CMD_READ = 0x02
No documentation found
const BRDCST = 0xFE
No documentation found
const CMD_UPDATE = 0x03
No documentation found
const CMD_STATUS = 0xB6
No documentation found
const CO2_PPM = 0x03
No documentation found
set_co2_elevation_m(word in meters)
should set elevation in meters above sea level, not implemented yet
get_co2_serial_number(byte out str[8])
returns 8 byte ASCII string, which should be the same as the number on the sticker
get_co2_elevation_m() return word
returns programmed elevation above sea level in meters this elevation is uses to calculate CO2 concentration correctly
get_co2_ppm() return word
returns a word with CO2 concentration in ppm note: if sensor is busy measuring the CO2 values, it will give garbage reply reply is checked for garbage and if so, *PREVIOUS* ppm value is returned
get_co2_status() return byte
returns status byte. bit_0 = error, bit_1 = warmup, bit_2 = calibration, bit_3 = idle
16f876a | 16f876a_t6603.jal |
16f877a | 16f877a_co2_t6603.jal |
Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | >=2.4g |
library for delays at any processor frequency. It's based on the JAL v2 compiler generator _usec_delay.
No dependency found
delay_7us()
delay_1us()
delay_3us()
delay_10us(byte in n)
delay_1ms(byte in n)
delay_8us()
delay_5us()
delay_2us()
delay_4us()
delay_100ms(word in n)
delay_9us()
delay_6us()
delay_7us()
fixed delay of 7 usec (no arguments)
delay_1us()
fixed delay of 1 usec (no arguments)
delay_3us()
fixed delay of 3 usec (no arguments)
delay_10us(byte in n)
Delays for n * 10 usec
delay_1ms(byte in n)
Delays for n * 1 msec
delay_8us()
fixed delay of 8 usec (no arguments)
delay_5us()
fixed delay of 5 usec (no arguments)
delay_2us()
fixed delay of 2 usec (no arguments)
delay_4us()
fixed delay of 4 usec (no arguments)
delay_100ms(word in n)
Delays for n * 100 msec
delay_9us()
fixed delay of 9 usec (no arguments)
delay_6us()
fixed delay of 6 usec (no arguments)
Author | Stef Mientki, Copyright (c) 2002 .. 2006, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | >=2.2 |
Outputs variables to output device. Writes formatted signed/unsiged bytes/words to the specified output device. Decimal (with fraction), Hex and Time formats available. Example: var sword BHL = -684 ; send the signed word to the LCD display ; total field width 6 chars, including sign and decimal ; with 2 digits behind the decimal point format_sword_dec(LCD_char,BHL,6,2) ; and now send the same signed word to the serial port format_sword_dec(Serial_HW_data,BHL,6,2)
No dependency found
format_time_hms(volatile byte out device,byte in HH, byte in MM, byte in SS)
format_byte_dec(volatile byte out device, byte in data, byte in n_tot, byte in n2)
format_time_hm_word(volatile byte out device,word in minutes)
format_sbyte_dec(volatile byte out device, sbyte in data, byte in n_tot, byte in n2)
format_sdword_dec(volatile byte out device, sdword in data, byte in n_tot, byte in n2)
format_dword_dec(volatile byte out device, dword in data, byte in n_tot, byte in n2)
format_dword_hex(volatile byte out device, dword in data)
format_word_dec(volatile byte out device, word in data, byte in n_tot, byte in n2)
format_byte_hex(volatile byte out device, byte in data)
format_word_hex(volatile byte out device, word in data)
format_sword_dec(volatile byte out device, sword in data, byte in n_tot, byte in n2)
format_time_hm(volatile byte out device,byte in HH, byte in MM)
_write_real_digit(volatile byte out device)
_write_digit(volatile byte out device, byte in digit, bit in point)
var byte _format_sign
No documentation found
var byte _format_digit
No documentation found
var byte _format_leader
global vars
var bit _format_signed
No documentation found
format_time_hms(volatile byte out device,byte in HH, byte in MM, byte in SS)
Displays a time in HH:MM:SS notation at specified position Hours and minutes are specified separate
format_byte_dec(volatile byte out device, byte in data, byte in n_tot, byte in n2)
writes decimal formatted byte to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_time_hm_word(volatile byte out device,word in minutes)
Displays a time in HH:MM notation at specified position the input is specified in minutes
format_sbyte_dec(volatile byte out device, sbyte in data, byte in n_tot, byte in n2)
writes decimal formatted signed byte to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_sdword_dec(volatile byte out device, sdword in data, byte in n_tot, byte in n2)
writes decimal formatted signed dword to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_dword_dec(volatile byte out device, dword in data, byte in n_tot, byte in n2)
writes decimal formatted dword to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_dword_hex(volatile byte out device, dword in data)
writes hex formatted dword to output device
format_word_dec(volatile byte out device, word in data, byte in n_tot, byte in n2)
writes decimal formatted word to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_byte_hex(volatile byte out device, byte in data)
writes hex formatted byte to output device
format_word_hex(volatile byte out device, word in data)
writes hex formatted word to output device
format_sword_dec(volatile byte out device, sword in data, byte in n_tot, byte in n2)
writes decimal formatted signed word to output device the output can be specified as a fraction n_tot = the total length (including sign and decimal point) n2 = number of digits behind the point
format_time_hm(volatile byte out device,byte in HH, byte in MM)
Displays a time in HH:MM notation at specified position Hours and minutes are specified separate
_write_real_digit(volatile byte out device)
_write_digit(volatile byte out device, byte in digit, bit in point)
16f648a | 16f648a_serial_format.jal |
16f648a | 16f648a_serial_print.jal |
16f876a | 16f876a_rtc_lcd.jal |
16f876a | 16f876a_tc77.jal |
16f876a | 16f876a_sht.jal |
16f877a | 16f877a_serial_print.jal |
16f877a | 16f877a_rtc_lcd.jal |
16f877a | 16f877a_serial_format.jal |
16f877a | 16f877a_print_serial_numbers.jal |
16f877a | 16f877a_lcd_format.jal |
16f88 | 16f88_print_serial_numbers.jal |
16f88 | 16f88_serial_print.jal |
18f2450 | 18f2450_serial_print.jal |
18f2450 | 18f2450_serial_format.jal |
18f4550 | 18f4550_serial_print.jal |
18f4550 | 18f4550_serial_format.jal |
Author | Eur van Andel, eur@fiwihex.nl Copyright (c) 2008 |
Adapted-by | |
Compiler | =2.4h |
The Sensirion SHT1x/SHT7x is a single chip relative humidity and temperature multi sensor module comprising a calibrated digital output. It comes in 5 flavors, with different accuracy and package style: sensor hum acc temp acc package SHT10 4.5 0.5 SMD (LCC) SHT11 3.0 0.4 SMD (LCC) SHT15 2.0 0.3 SMD (LCC) SHT71 3.0 0.4 4-pin single-in-line SHT75 1.8 0.3 4-pin single-in-line all consist of the same silicon: the less accurate models are sold cheaper. My experience is mixed: I've seen some consistent +2C offset in temperature, but good humidty measurements. The 4-pin package breaks when you touch it. The SMD package has naked tracks underneath: you can't route under it! If exposed to >95% RH for 10 minutes, these sensors will go beserk and need <60% RH for an hour to recover. You might try heating them. protocol is close to I2C, but not the same. Remember to pull up DATA. 0b0000_0011 starts temperature measurement 0b0000_0101 starts humidity measurement device returns three bytes: MSB, LSB and CRC higher functions don't do a CRC check
http://www.sensirion.com/en/01_humidity_sensors/00_humidity_sensors.htm
No dependency found
read_raw_hum_sht(byte out MSB, byte out LSB, byte out CRC)
read_hum_word_sht(word out hum)
sht_get_data(byte out x)
sht_start()
sht_put_ack()
sht_conn_reset()
sht_wait_ack()
sht_reset()
sht_put_data(byte in x)
read_hum_sht(byte out hum)
read_raw_temp_sht(byte out MSB, byte out LSB, byte out CRC)
read_raw_hum_sht(byte out MSB, byte out LSB, byte out CRC)
read raw 12-bit humidity from SHT default value of resolution bit is 12 bit RH SHT takes 55 ms for measurement @ 12 bits we will wait 70 ms SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every 500ms
read_hum_word_sht(word out hum)
read humidity from SHT, result in word precision 0.01%RH SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every 500ms
sht_get_data(byte out x)
receive one byte from the SHT
sht_start()
send start
sht_put_ack()
send ACK
sht_conn_reset()
reset SHT interface, must be followed with sht_start and command
sht_wait_ack()
pretend to wait for ACK
sht_reset()
reset SHT
sht_put_data(byte in x)
send one byte to the SHT
read_hum_sht(byte out hum)
read humidity from SHT, result in byte precision 1%RH SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every 500ms
read_raw_temp_sht(byte out MSB, byte out LSB, byte out CRC)
read raw 14-bit temperature from SHT default value of resolution bit is 14 bit temperature SHT takes 210 ms for measurement @ 14 bits we will wait 300 ms SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every two seconds!
16f876a | 16f876a_sht.jal |
Author | Stef Mientki, Copyright (C) 2005 Stef Mientki |
Adapted-by | Joep Suijs. |
Compiler | >=2.4g |
Hardware implementation of I2C (single) master.
No dependency found
const _i2c_1mhz = (target_clock / (4 * 1000_000)) - 1
const _i2c_100khz = (target_clock / (4 * 100_000)) - 1
const _i2c_400khz = (target_clock / (4 * 400_000)) - 1
const _i2c_1mhz = (target_clock / (4 * 1000_000)) - 1
No documentation found
const _i2c_100khz = (target_clock / (4 * 100_000)) - 1
some constants needed for the baudrate generator
const _i2c_400khz = (target_clock / (4 * 400_000)) - 1
No documentation found
i2c_restart()
i2c_restart - Sends Restart bit and waits untill finished
i2c_initialize()
if the device has changed, change the speed if necessary
i2c_stop()
i2c_stop - Sends Stop bit and waits until finished
i2c_start()
i2c_start - Sends Start bit and waits untill finished
i2c_receive_byte(bit in ACK ) return byte
i2c_receive_byte - start receiving of a byte and waits till finished if param ACK is true, the byte is acknowledged and next bytes can be received. if param ACK is false, the byte is nacked and a stop *should be* sent. note: this behavior is inverted from the line level and orignal library, but consistent with the i2c_software library.
i2c_transmit_byte(byte in data) return bit
i2c_transmit_byte -
16f877a | 16f877a_i2c_hw_l1.jal |
Author | Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | >=2.4i |
Common and useful functions and procedure to implement an I2C slave
No dependency found
i2c_hw_slave_init(byte in height_bits_icaddress)
setup an i2c slave, with low address (not high addresses coded with 10-bits) The passed address must be 8-bits long: it's a 7-bits address + the 8th R/W bit A global "i2c_enable_start_stop_interrupts" constant can be defined to so interrupts are generated on Start/Stop signals. /!\ careful: calling this procedure will enable interrupts (global, peripherals and i2c)
i2c_hw_slave_write_i2c(byte in what)
write a byte to i2c bus
i2c_hw_slave_read_i2c() return byte
read a byte from i2c buffer and returns it
16f88 | 16f88_i2c_hw_slave_check_bus.jal |
16f88 | 16f88_i2c_hw_slave_echo.jal |
Author | Sebastien Lelong, Joep Suijs, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
this library provides an ISR to implement a stateful i2c hardware slave. This is a jalv2 implementation of Microchip Application Note AN734. According to AN734, there are 5 possible i2c states. During ISR, each of this states are detected. This ISR provides a standard skeleton to implement an i2c hardware slaves, while client code must implement several callbacks the ISR is expecting to call while processing states. Here there are: - procedure i2c_hw_slave_on_state_1(byte in _trash): called when i2c address matches (master starts a talk) - procedure i2c_hw_slave_on_state_2(byte in rcv): called when master is writing a byte. Slave is thus receiving this byte. This callback takes this bytes as argument - procedure i2c_hw_slave_on_state_3(): called when master wants to read a byte from slave. Thus, slave should send a byte (for instance, using i2c_hw_slave_write_i2c from i2c_hw_slave.jal library) - procedure i2c_hw_slave_on_state_4(): called when master still wants to read a byte from slave. That is, master required to read (state 3) and now still want to read a byte - procedure i2c_hw_slave_on_state_5(): called when master does not want to talk to slave anymore usually a good place to reset data or slave's logic - procedure i2c_hw_slave_on_error(): called when something wrong happens. You can do what you want in this case, like resetting the PIC, log some information using usart, ... => called any cases other than states 1, 2, 3, 4 or 5
- AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798
No dependency found
i2c_hw_slave_isr_handler()
i2c ISR handler. Detects states a call appropriate procedures
16f88 | 16f88_i2c_hw_slave_echo.jal |
Author | Sebastien Lelong, Joep Suijs, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
this library provides an message interface to i2c hardware slave. It relies on the jalv2 implementation of Microchip Application Note AN734. The user needs to supply a procedure to process the received message. Basically, this i2c slave waits for a full message to arrive. Then it calls the user procedure to process the message and (optional) prepare a response. Subsequently, this lib will pass the response data over to the master, if it wants to have them. See corresponding sample for more details.
- AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798
var byte i2c_buffer[I2C_BUFFER_SIZE]
var bit i2c_datapresent -- datapresent flag
const bit i2c_enable_start_stop_interrupts = true
var byte i2c_index -- i2c index (pointer)
i2c_hw_slave_on_stop()
i2c_hw_slave_on_state_4()
i2c_hw_slave_on_state_3()
i2c_hw_slave_on_error()
i2c_hw_slave_on_state_1(byte in _trash)
i2c_hw_slave_on_start()
i2c_call_process_message()
i2c_hw_slave_on_state_2(byte in rcv)
i2c_hw_slave_on_state_5()
var byte i2c_buffer[I2C_BUFFER_SIZE]
No documentation found
var bit i2c_datapresent -- datapresent flag
No documentation found
const bit i2c_enable_start_stop_interrupts = true
No documentation found
var byte i2c_index -- i2c index (pointer)
vars
i2c_hw_slave_on_stop()
No documentation found
i2c_hw_slave_on_state_4()
this callback is used when master, after having read something, still wants to read and get data from us.
i2c_hw_slave_on_state_3()
this callback is used when master wants to read something from us. It should use i2c_hw_slave_write() to send something
i2c_hw_slave_on_error()
this callback is used when something wrong happened during communication between master and us
i2c_hw_slave_on_state_1(byte in _trash)
this callback is used when master wants to talk to us and our i2c address has been recognized
i2c_hw_slave_on_start()
No documentation found
i2c_call_process_message()
No documentation found
i2c_hw_slave_on_state_2(byte in rcv)
This callback is used when master sends a data byte
i2c_hw_slave_on_state_5()
this callback is used when master does not want to talk with us anymore... This is an appropriate place to reset data for instance
16f877a | 16f877a_i2c_hw_slave_eeprom_simulator.jal |
16f877a | 16f877a_i2c_hw_slave_msg.jal |
16f88 | 16f88_i2c_hw_slave_msg.jal |
16f88 | 16f88_i2c_hw_slave_eeprom_simulator.jal |
Author | Joep Suijs, Copyright (C) 2008 Joep Suijs |
Adapted-by | |
Compiler | >=2.4g |
Level1 implementation of I2C (single) master.
No dependency found
i2c_receive_byteaddr(byte in i2c_address, byte in addr, byte in i2c_rx_count) return bit
i2c_send_receive(byte in i2c_address, byte in i2c_tx_count, byte in i2c_rx_count) return bit
i2c_receive_wordaddr(byte in i2c_address, word in addr, byte in i2c_rx_count) return bit
i2c_receive_byteaddr(byte in i2c_address, byte in addr, byte in i2c_rx_count) return bit
i2c_receive_byteaddr - send a byte address and receive a string from an i2c slave
i2c_send_receive(byte in i2c_address, byte in i2c_tx_count, byte in i2c_rx_count) return bit
i2c_send_receive - send a string to an i2c slave and receive bytes back This funtion uses two global i2c buffers, one for transmit (tx) and one for receive (rx). The address of the slave (higher 7 bits), number of bytes to transmit and number of bytes to receive are parameters. returns true if all went well.
i2c_receive_wordaddr(byte in i2c_address, word in addr, byte in i2c_rx_count) return bit
i2c_receive_wordaddr - send a word address and receive a string from an i2c slave
16f648a | 16f648a_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_hw_l1.jal |
16f877a | 16f877a_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_sw_master_check_bus.jal |
16f877a | 16f877a_i2c_sw_master_echo.jal |
16f88 | 16f88_i2c_sw_master_echo.jal |
16f88 | 16f88_i2c_sw_master_check_bus.jal |
16f88 | 16f88_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_l1.jal |
18f4550 | 18f4550_i2c_sw_l1.jal |
Author | Wouter van Ooijen, Copyright (C) 1998, 1999 Wouter van Ooijen |
Adapted-by | Joep Suijs. |
Compiler | >=2.4g |
Software implementation of I2C (single) master.
i2c_initialize()
i2c_initialize - initialize the software i2c bus The output latch values are always low, the lines are switched open-collector fashion by manipulating the direction registers.
i2c_stop()
i2c_stop - output a stop condition
i2c_start()
i2c_start - output a start condition
i2c_restart()
i2c_restart - output a (re)start condition A restart is a start without a previous stop. This procedure is provided as part of the API to maintain compatibility with the i2c hardware master lib.
_i2c_bit_out(bit in x)
_i2c_bit_out- output a single bit (for internal use only)
_i2c_bit_in(bit out x)
_i2c_bit_in- input a single bit (for internal use only)
_i2c_wait()
_i2c_wait - wait for a change to settle (for internal use only) The delay is determined by i2c_bus_speed and is 1/4 of the cycle time. Given the delay resolution of 1 us and all actions required by i2c_software routines, the actual bus speed will be lower then the configured maximum.
i2c_receive_byte( bit in ack) return byte
i2c_receive_byte - read one byte The ACK flag indicated if the byte read must be acked. In general, all bytes read by the master are acked, except the last one. Failing to NACK the last byte read will give unpredictable results. (Often it will provide repeatable sequences, where one out of 2 to 4 of the reads from a specific device is correct. You are warned!)
i2c_transmit_byte( byte in x ) return bit
i2c_transmit_byte - output one byte
16f648a | 16f648a_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_sw_master_check_bus.jal |
16f877a | 16f877a_i2c_sw_master_echo.jal |
16f88 | 16f88_i2c_sw_master_echo.jal |
16f88 | 16f88_i2c_sw_master_check_bus.jal |
16f88 | 16f88_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_l1.jal |
18f4550 | 18f4550_i2c_sw_l1.jal |
Author | Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
this lib is able to handle the GP2D02 lib, reading distance measure with this IR Ranger. You can either use the read procedure, or access the pseudo-variable to retrieve distance measures. When defining pins the ranger is connected to to, it's important to set them as "volatile" (level will go low/high within function call) See sample(s) for more.
- datasheet: http://www.datasheetcatalog.org/datasheet/Sharp/mXvryzu.pdf
reading a distance can take quite a long time, approx. 74ms. See datasheet for more, but you should remember this while using this IR ranger
gp2d02_read_pins(volatile bit out pin_vin, volatile bit in pin_vout) return byte
No documentation found
16f88 | 16f88_ir_ranger_gp2d02.jal |
Author | Wouter van Ooijen, Copyright (c) 1998, all rights reserved. |
Adapted-by | Joep Suijs, Rob Hamerling |
Compiler | >=2.4 |
- ASCII text character constant definitions - case conversion procedures toupper and tolower use of toupper var byte char = "b" -- assign lower case "b" to char toupper(char) -- char now contains "B"
No dependency found
const byte ASCII_VT = 11
const byte ASCII_NAK = 21
const byte ASCII_EOT = 04
const byte ASCII_GS = 29
const byte ASCII_CAN = 24
const byte ASCII_DC2 = 18
const byte ASCII_SOH = 01
const byte ASCII_SO = 14
const byte ASCII_US = 31
const byte ASCII_SI = 15
const byte ASCII_BEL = 07
const byte ASCII_EM = 25
const byte ASCII_RS = 30
const byte ASCII_CR = 13
const byte ASCII_DC3 = 19
const byte ASCII_ENQ = 05
const byte ASCII_FS = 28
const byte ASCII_DEL = 127
const byte ASCII_STX = 02
const byte ASCII_DLE = 16
const byte ASCII_ACK = 06
const byte ASCII_HT = 09
const byte ASCII_LF = 10
const byte ASCII_DC4 = 20
const byte ASCII_ESC = 27
const byte ASCII_SUB = 26
const byte ASCII_FF = 12
const byte ASCII_ETB = 23
const byte ASCII_DC1 = 17
const byte ASCII_SP = 32
const byte ASCII_SYN = 22
const byte ASCII_ETX = 03
const byte ASCII_BS = 08
const byte ASCII_NULL = 00
const byte ASCII_VT = 11
No documentation found
const byte ASCII_NAK = 21
No documentation found
const byte ASCII_EOT = 04
No documentation found
const byte ASCII_GS = 29
No documentation found
const byte ASCII_CAN = 24
No documentation found
const byte ASCII_DC2 = 18
No documentation found
const byte ASCII_SOH = 01
No documentation found
const byte ASCII_SO = 14
No documentation found
const byte ASCII_US = 31
No documentation found
const byte ASCII_SI = 15
No documentation found
const byte ASCII_BEL = 07
No documentation found
const byte ASCII_EM = 25
No documentation found
const byte ASCII_RS = 30
No documentation found
const byte ASCII_CR = 13
No documentation found
const byte ASCII_DC3 = 19
No documentation found
const byte ASCII_ENQ = 05
No documentation found
const byte ASCII_FS = 28
No documentation found
const byte ASCII_DEL = 127
No documentation found
const byte ASCII_STX = 02
No documentation found
const byte ASCII_DLE = 16
No documentation found
const byte ASCII_ACK = 06
No documentation found
const byte ASCII_HT = 09
No documentation found
const byte ASCII_LF = 10
No documentation found
const byte ASCII_DC4 = 20
No documentation found
const byte ASCII_ESC = 27
No documentation found
const byte ASCII_SUB = 26
No documentation found
const byte ASCII_FF = 12
No documentation found
const byte ASCII_ETB = 23
No documentation found
const byte ASCII_DC1 = 17
No documentation found
const byte ASCII_SP = 32
No documentation found
const byte ASCII_SYN = 22
No documentation found
const byte ASCII_ETX = 03
No documentation found
const byte ASCII_BS = 08
No documentation found
const byte ASCII_NULL = 00
No documentation found
toupper(byte in out char)
toupper - convert byte to upper case
tolower(byte in out char)
tolower - convert byte to lower case
Author | Javier Martínez, Copyright (c) 2003, all rights reserved. |
Adapted-by | Eur van Andel, eur@fiwihex.nl |
Compiler | >=2.4g |
This library consist of a single funtion: getkey() that scans a 4x4 matrix keyboard. it needs two variables: keydrive and keyscan.
No dependency found
const col1 = 0b0000_1000
var byte scan0, scan1, scan2, scan3
const row4 = 0b0000_1000
const row1 = 0b0000_0100 -- match these constants to your soldering skills
const col4 = 0b0000_0001
const col2 = 0b0000_0010
const col3 = 0b0000_0100
const row3 = 0b0000_0010
const row2 = 0b0000_0001
const col1 = 0b0000_1000
No documentation found
var byte scan0, scan1, scan2, scan3
No documentation found
const row4 = 0b0000_1000
No documentation found
const row1 = 0b0000_0100 -- match these constants to your soldering skills
No documentation found
const col4 = 0b0000_0001
No documentation found
const col2 = 0b0000_0010
No documentation found
const col3 = 0b0000_0100
No documentation found
const row3 = 0b0000_0010
No documentation found
const row2 = 0b0000_0001
No documentation found
getkey() return byte
No documentation found
16f876a | 16f876a_keyboard_lcd.jal |
16f877a | 16f877a_keyboard_lcd.jal |
Author | Rob Hamerling, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | Eur van Andel, Joep Suijs (refactoring) |
Compiler | >=2.4g |
Nibble interface for HD44780 compatible alphanumeric LCD screens. . Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en' and - 1 port nibble for data: 'lcd_dataport' or - 4 lines for data: 'lcd_d4' .. 'lcd_d7' note: a 'port nibble' - the lower or higher 4 bits of a port - give faster and more compact code then random selected data lines. . Directions for use of this library in application programs (in this sequence): 1. Declare the following constants: const byte LCD_ROWS = 2 -- 1, 2 or 4 lines const byte LCD_CHARS = 16 -- 8, 16 or 20 chars per line and variables (aliases): var bit lcd_en is pin_A4 -- trigger var bit lcd_rs is pin_A5 -- cmd/data select and variables (aliases): var byte lcd_dataport is portA_low -- 4 data pins or var bit lcd_d4 is pin_A3 -- databit d4 pin var bit lcd_d5 is pin_A1 -- databit d5 pin var bit lcd_d6 is pin_C0 -- databit d6 pin var bit lcd_d7 is pin_C2 -- databit d7 pin . 2. Set the chosen LCD dataport and handshake pins to output: pin_A4_direction = output pin_A5_direction = output and portA_low_direction = all_output or pin_A3_direction = output -- set data pin as output pin_A1_direction = output -- set data pin as output pin_C0_direction = output -- set data pin as output pin_C2_direction = output -- set data pin as output . 3. Include this library. . 4. Call lcd_init() to initialize the lcd controller. . Above is an example for a 2x16 LCD. . See hd_44780_common for the LCD API.
_lcd_write_data(byte in value)
__lcd_write( byte in value )
__lcd_write_nibble( byte in value )
_lcd_write_command(byte in value)
lcd_init()
Initialize LCD controller to 4-bit mode
_lcd_write_data(byte in value)
Sends data byte into LCD
__lcd_write( byte in value )
Sends byte into LCD (this procedure is only used inside this library)
__lcd_write_nibble( byte in value )
Sends low nibble into LCD Can be used for both commands and data (requires no wait cycli inbetween upper and lower nibble) (this routine is only used inside this file)
_lcd_write_command(byte in value)
Sends command byte into LCD For slow commands an extra delay should be added
Author | Rob Hamerling, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | Eur van Andel, Joep Suijs (refactoring) |
Compiler | >=2.4g |
Port interface for HD44780 compatible alphanumeric LCD screens. Uses 8 bit wide datapath + 2 handshake lines (total 10 PIC pins). Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en' - 1 complete port for data: 'lcd_dataport' or - 2 pins for handshake: 'lcd_rs' and 'lcd_en' - 8 lines for data: 'lcd_d0' .. 'lcd_d7' note: a 'port nibble' - the lower or higher 4 bits of a port - give faster and more compact code then random selected data lines. . Directions for use of this library in application programs (in this sequence): 1. Declare the following constants: const byte LCD_ROWS = 2 -- 1, 2 or 4 lines const byte LCD_CHARS = 16 -- 8, 16 or 20 chars per line and variables (aliases): var bit lcd_rs is pin_D2 -- cmd/data select var bit lcd_en is pin_D3 -- trigger and variables (aliases): var byte lcd_dataport is portF -- 8 data pins or var byte lcd_dataport_low is portD_high -- 4 low order data pins var byte lcd_dataport_high is portC_high -- 4 high order data pins or var bit lcd_d0 is pin_D0 -- databit d0 pin var bit lcd_d1 is pin_D1 -- databit d1 pin var bit lcd_d2 is pin_C6 -- databit d2 pin var bit lcd_d3 is pin_C7 -- databit d3 pin var bit lcd_d4 is pin_B0 -- databit d4 pin var bit lcd_d5 is pin_B1 -- databit d5 pin var bit lcd_d6 is pin_C0 -- databit d6 pin var bit lcd_d7 is pin_C2 -- databit d7 pin . 2. Set the chosen LCD handshake pins to output: pin_D2_direction = output pin_D3_direction = output and the data port to output: portF_direction = ALL_OUTPUT or 2 half data ports to output: portD_high_direction = ALL_OUTPUT portC_high_direction = ALL_OUTPUT or 8 individual pins to outout pin_D0_direction = output -- set data pin as output pin_D1_direction = output -- set data pin as output pin_C6_direction = output -- set data pin as output pin_C7_direction = output -- set data pin as output pin_B0_direction = output -- set data pin as output pin_B1_direction = output -- set data pin as output pin_C0_direction = output -- set data pin as output pin_C2_direction = output -- set data pin as output . 3. Include this library. . 4. Call lcd_init() to initialize the lcd controller. . Above is an example for a 2x16 LCD. . See hd_44780_common for the LCD API.
lcd_init()
Initialise the LCD controller and API
_lcd_write_data(byte in value)
Sends data byte into LCD
__lcd_write( byte in value )
Sends byte into the LCD (this procedure is only used inside this file).
_lcd_write_command(byte in value)
Sends command byte into LCD For slow commands an extra delay should be added
16f727 | 16f727_lcd_hd44780_8_1.jal |
16f727 | 16f727_lcd_hd44780_8_4.jal |
16f877a | 16f877a_lcd_hd44780_8_4.jal |
16f877a | 16f877a_lcd_hd44780_8_1.jal |
16f887 | 16f887_lcd_hd44780_8_1.jal |
16f887 | 16f887_lcd_hd44780_8_4.jal |
18f4685 | 18f4685_lcd_hd44780_8_4.jal |
18f4685 | 18f4685_lcd_hd44780_8_1.jal |
18f6310 | 18f6310_lcd_hd44780_8_1.jal |
18f6310 | 18f6310_lcd_hd44780_8_8.jal |
18f6310 | 18f6310_lcd_hd44780_8_4.jal |
Author | Richard Zengerink, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | >=2.4j |
Common API for HD44780 based LCD . Procedures which can be used by application program: . * lcd_write_char( byte in value ): writes 'value' to lcd example: lcd_write_char( "E" ) or lcd_write_char( 69 ) . * lcd = value: writes 'value' to lcd example: lcd = "E" or lcd = 69 . * lcd_cursor_position(byte in line, byte in pos): places the cursor on position (pos) in line (line) (zero based!) example: lcd_new_line_cursor_position (1, 8) . * lcd_shift_left(byte in value): shifts the display [value] times to the left without changing DDRAM data. example: lcd_shift_left(4) or lcd_shift_left(variable) . * lcd_shift_right(byte in value): shifts the display [value] times to the right without changing DDRAM data. example: lcd_shift_right(12) or lcd_shift_right(variable) . * lcd_cursor_shift_left(byte in value): shifts the cursor [value] times to the left without changing display contents and DDRAM data. example: lcd_cursor_shift_left(8) or lcd_cursor_shift_left(variable) . * lcd_cursor_shift_right(byte in value): shifts the cursor [value] times to the right without changing display contents and DDRAM data. example: lcd_cursor_shift_right(3) or lcd_cursor_shift_right(variable) . * lcd_clear: Write "20H" to DDRAM and set DDRAM address to "00H" from AC This will clear the display. . * lcd_home: Set DDRAM address to "00H" from AC and return cursor to its original position if shifted. The contents of DDRAM are not changed. . * lcd_cursor_blink_display(bit in cursor,bit in blink,bit in display): sets the underline cursor on/off, let the block-cursor blinking/off and puts the display on/off example: lcd_cursor_blink_display(on,off,on) . * lcd_clear_line ( byte in line ) clears the line [line] of the lcd including DDRAM data of that line example: lcd_clear_line(1) . * lcd_progress(byte in line, byte in amount) create a progress bar on line [line] with a lenght of [amout] example: lcd_progress(2,12)
No dependency found
const LCD_DISPLAY_SHIFT_RIGHT = 0b_0001_1100
const LCD_CURSOR_SHIFT_R_VAL = 0b_0001_0100
const LCD_DISPLAY_SHIFT_LEFT = 0b_0001_1000
const LCD_RETURN_HOME = 0b_0000_0010
const LCD_CLEAR_DISPLAY = 0b_0000_0001
const LCD_SET_DDRAM_ADDRESS = 0b_1000_0000
const LCD_DISPLAY_ONOFF = 0b_0000_1000
var volatile byte lcd_pos = 0
const LCD_CURSOR_SHIFT_L_VAL = 0b_0001_0000
lcd_clear_screen()
lcd_clear_line(byte in line)
lcd_shift_right(byte in nr)
lcd_writechar(byte in data)
lcd_cursor_blink_display(bit in cursor, bit in blink, bit in display)
lcd_cursor_shift_right(byte in nr)
lcd_shift_left(byte in nr)
lcd_clearscreen()
lcd_home()
lcd_write_char(byte in data)
lcd_cursor_position(byte in line, byte in pos)
lcd'put(byte in data)
lcd_cursor_shift_left(byte in nr)
lcd_progress(byte in line, byte in amount, byte in pattern)
const LCD_DISPLAY_SHIFT_RIGHT = 0b_0001_1100
No documentation found
const LCD_CURSOR_SHIFT_R_VAL = 0b_0001_0100
No documentation found
const LCD_DISPLAY_SHIFT_LEFT = 0b_0001_1000
No documentation found
const LCD_RETURN_HOME = 0b_0000_0010
No documentation found
const LCD_CLEAR_DISPLAY = 0b_0000_0001
some constants to control the lcd
const LCD_SET_DDRAM_ADDRESS = 0b_1000_0000
No documentation found
const LCD_DISPLAY_ONOFF = 0b_0000_1000
No documentation found
var volatile byte lcd_pos = 0
No documentation found
const LCD_CURSOR_SHIFT_L_VAL = 0b_0001_0000
No documentation found
lcd_clear_screen()
lcd_clear_screen - clears the LCD
lcd_clear_line(byte in line)
lcd_clear_line - clears the line "line" of the LCD
lcd_shift_right(byte in nr)
lcd_shift_right - shifts the complete display one position to the right
lcd_writechar(byte in data)
Deprecated
lcd_cursor_blink_display(bit in cursor, bit in blink, bit in display)
lcd_cursor_blink_display - (re)sets cursor blink and puts display on/off . params: cursor: enable or disable the fixed underline cursor blink: enable or disable blinking of the block-cursor (so block blinking or off) display: enable or disable the whole display
lcd_cursor_shift_right(byte in nr)
lcd_cursor_shift_right - shifts cursor one position to the right
lcd_shift_left(byte in nr)
lcd_shift_left - shifts the complete display one position to the left
lcd_clearscreen()
Deprecated
lcd_home()
lcd_home - cursor returns home(line 0, position 0)
lcd_write_char(byte in data)
lcd_write_char - write one char to LCD
lcd_cursor_position(byte in line, byte in pos)
lcd_cursor_position - Specify row and column (0-based) . About cursor positions: the LCDs are internally 2x40 char devices. The first line starts at offset 0, the second line at offset 64 (0x40). With 4 line devices the third and fourth line are addressed as extensions of the first and second line by adding an offset. For a 4x20 line device the offset is 20, for a 4x16 line display the offset is 16 or 20. Declare the constant LCD_CHARS as appropriate for your screen (you may have to specify 20 even if your display has only 16 chars!). Note: Some 1x16 LCDs are implemented as 2x8 line LCDs, which means that the second half of the line has to be handled as a second line.
lcd'put(byte in data)
lcd'put - write one char to screen (pseudo var, enables streams)
lcd_cursor_shift_left(byte in nr)
lcd_cursor_shift_left - shifts cursor one position to the left
lcd_progress(byte in line, byte in amount, byte in pattern)
lcd_progress- Displays a progress bar The progress bar starts at position 0 of a line. line: line on which progress bar is displayed amount: number of bar chars that are displayed (0xFF is a common pattern)
_lcd_restore_cursor()
_lcd_restore_cursor - sets the cursor to the position in the shadow register (this routine is only used inside this file)
_hd44780_init()
_hd44780_init - Initialise display (not realy internal, but not for users) This procedure is called from lcd_init of the interface used. lcd_init brings up the interface and powers up the display. This procedure sets the display in the pre-defined startposition (clear screen, no cursor etc).
_lcd_line2index(byte in line) return byte
_lcd_line2index - internal function - calculate index from line number
Author | Joep Suijs, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4g |
Software serial interface for HD44780 compatible alphanumeric LCD screens. -- Directions for use of this library in application programs (in this sequence): 1. Declare the following constants: const byte LCD_ROWS = 2 -- 1, 2 or 4 lines const byte LCD_CHARS = 16 -- 8, 16 or 20 chars per line and variables (aliases): var bit serial_sw_tx_pin is pin_d0 -- pin on which lcd is connected 2. Set the chosen LCD dataport and handshake pins to output: pin_d0_direction = output 3. Include this library. 4. Call lcd_init() to initialize the lcd controller. Above is an example for a 2x16 LCD, connected to pin d0 See hd_44780_common for the LCD API.
const serial_sw_baudrate = 57600
var bit lcd_rs_shadow
var bit serial_sw_rx_pin ; dummy to include lib; will be optimised away.
const bit serial_sw_invert = true ; normal (low active) serial comms
__lcd_write_nibble( byte in value )
__lcd_write( byte in value )
_lcd_write_command(byte in value)
_lcd_write_data(byte in value)
const serial_sw_baudrate = 57600
No documentation found
var bit lcd_rs_shadow
No documentation found
var bit serial_sw_rx_pin ; dummy to include lib; will be optimised away.
No documentation found
const bit serial_sw_invert = true ; normal (low active) serial comms
No documentation found
lcd_backlight(bit in onoff)
lcd_backlight - turn backlite on/off
lcd_init()
lcd_backlight_variable(byte in value)
lcd_backlight_variable - set backlight level
__lcd_write_nibble( byte in value )
sends low nibble from value to the LCD can be used for both commands and data (requires no wait cycli inbetween upper and lower nibble) (this routine is only used inside this file)
__lcd_write( byte in value )
sends byte from value to register of the LCD (this procedure is only used inside this file)
_lcd_write_command(byte in value)
sends command byte in value to LCD for slow commands an extra delay should be added
_lcd_write_data(byte in value)
sends data byte in value to LCD for slow commands an extra delay should be added
Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | >=2.4i |
Read from or write to EEPROM/data a byte, word or double word. Available procedures: * data_eeprom_read(, ) * data_eeprom_write( , ) * data_eeprom_read_word( , ) * data_eeprom_write_word( , ) * data_eeprom_read_dword( , ) * data_eeprom_write_dword( , ) Available functions: * = data_eeprom( ) * = data_eeprom_word( ) * = data_eeprom_dword( ) In all cases is a position relative to the beginning of EEPROM/data memory, thus starts at 0. Examples of use: * Read a byte of EEPROM at offset 7 into x: var byte x data_eeprom_read(7, x) * Read a word from EEPROM at offset 4 into y: var word y y = data_eeprom_word(4) * Write a byte to EEPROM at offset 18: data_eeprom_write(18, 0b1111_0000)
- Write-protect bits in configuration memory may prohibit writing. - Writing to locations outside the available memory range may have unexpected effects! - Summary of changes + Changed byte-offset to word-offset for larger EEPROMs with 18Fs + Offset and flags settings for read and write in separate procedure. + Moved check for write completed ahead of read and write, for performance (ahead of read needed for read back of same offset). + added 'pragma inline' to several procedures + some other code optimizations + added support for PICs with deviating register names, like 'EEDAT' or EEDATL in stead of 'EEDATA' and EEADRL in stead of EEADR.
No dependency found
data_eeprom_read_word(word in offset, word out data)
data_eeprom_read_dword(word in offset, dword out data)
data_eeprom_write_word(word in offset, word in data)
data_eeprom_write_dword(word in offset, dword in data)
data_eeprom_write(word in offset, byte in data)
data_eeprom_read(word in offset, byte out data)
data_eeprom(word in offset) return byte
data_eeprom_dword(word in offset) return dword
data_eeprom_word(word in offset) return word
data_eeprom_read_word(word in offset, word out data)
Read word from data eeprom at given offset Result is stored in the passed in-argument
data_eeprom_read_dword(word in offset, dword out data)
Read a dword from data eeprom at given offset Result is stored in the passed in-argument
data_eeprom_write_word(word in offset, word in data)
Write word to data eeprom at given offset
data_eeprom_write_dword(word in offset, dword in data)
Write dword to data eeprom at given offset
data_eeprom_write(word in offset, byte in data)
Write byte to data EEPROM at given offset
data_eeprom_read(word in offset, byte out data)
Read byte from data EEPROM at given offset Result is stored in the passed in-argument
_prepare_eeprom_access(word in offset)
No documentation found
data_eeprom(word in offset) return byte
Read byte from data EEPROM at given offset and return result
data_eeprom_dword(word in offset) return dword
Read dword from data eeprom at given offset and return result
data_eeprom_word(word in offset) return word
Read word from data eeprom at given offset and return result
16f648a | 16f648a_data_eeprom.jal |
16f88 | 16f88_data_eeprom.jal |
16f88 | 16f88_remember_me.jal |
18f2620 | 18f2620_data_eeprom.jal |
Author | Joep Suijs, Copyright (c) 2007..2008, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | >=2.2 |
Outputs variables to output device. formats: _decimal and _hex vars: bit, byte, sbyte, word, sword, dword, sdword Example: var sword BHL = -684 ; print the signed word to the LCD display print_sword_dec(LCD_char, BHL) ; and now print the same signed word to the serial port print_sword_dec(Serial_HW_data, BHL)
print_dword_binary(volatile byte out device, dword in data)
print_bit_highlow(volatile byte out device, bit in data)
print_word_hex(volatile byte out device, word in data)
print_sbyte_dec(volatile byte out device, sbyte in data)
print_crlf(volatile byte out device)
print_sdword_dec(volatile byte out device, sdword in data)
print_sword_dec(volatile byte out device, sword in data)
print_string(volatile byte out device, byte in str[])
print_word_binary(volatile byte out device, word in data)
print_byte_dec(volatile byte out device, byte in data)
print_byte_hex(volatile byte out device, byte in data)
print_dword_hex(volatile byte out device, dword in data)
print_bit_10(volatile byte out device, bit in data)
print_byte_binary(volatile byte out device, byte in data)
print_dword_dec(volatile byte out device, dword in data)
print_bit_truefalse(volatile byte out device, bit in data)
print_word_dec(volatile byte out device, word in data)
_print_suniversal_dec(volatile byte out device, sdword in data, sdword in digit_divisor, byte in digit_number)
_print_universal_dec(volatile byte out device, dword in data, sdword in digit_divisor, byte in digit_number)
var bit print_prefix = false
No documentation found
const byte nibble2hex[] = "0123456789ABCDEF" -- conversion string
No documentation found
print_dword_binary(volatile byte out device, dword in data)
No documentation found
print_bit_highlow(volatile byte out device, bit in data)
No documentation found
print_word_hex(volatile byte out device, word in data)
No documentation found
print_sbyte_dec(volatile byte out device, sbyte in data)
No documentation found
print_crlf(volatile byte out device)
No documentation found
print_sdword_dec(volatile byte out device, sdword in data)
No documentation found
print_sword_dec(volatile byte out device, sword in data)
No documentation found
print_string(volatile byte out device, byte in str[])
No documentation found
print_word_binary(volatile byte out device, word in data)
No documentation found
print_byte_dec(volatile byte out device, byte in data)
No documentation found
print_byte_hex(volatile byte out device, byte in data)
No documentation found
print_dword_hex(volatile byte out device, dword in data)
No documentation found
print_bit_10(volatile byte out device, bit in data)
No documentation found
print_byte_binary(volatile byte out device, byte in data)
No documentation found
print_dword_dec(volatile byte out device, dword in data)
No documentation found
print_bit_truefalse(volatile byte out device, bit in data)
No documentation found
print_word_dec(volatile byte out device, word in data)
No documentation found
_print_suniversal_dec(volatile byte out device, sdword in data, sdword in digit_divisor, byte in digit_number)
No documentation found
_print_universal_dec(volatile byte out device, dword in data, sdword in digit_divisor, byte in digit_number)
No documentation found
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
performs PWM operations on CCP1 The target must support this.
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
pwm1_off()
pwm1_set_percent_dutycycle(byte in percent)
pwm1_set_dutycycle_highres(word in duty)
pwm1_set_dutycycle(byte in duty)
pwm1_on()
var byte ccpr1l_shadow = 0
No documentation found
var byte ccp1con_shadow = 0
No documentation found
pwm1_off()
No documentation found
pwm1_set_percent_dutycycle(byte in percent)
This procedure set duty cycle using a percentage According to what has been computed by pwm_set_frequency(), it converts the duty percent to a value suitable for the selected pwm frequency.
pwm1_set_dutycycle_highres(word in duty)
sets dutycyle in high resolution mode the word passed to the procedure represents the high resolution value of the duty cycle: * duty1h<0:1> are the 2 LSbits * duty1h<2:9> are the 8 MSbits Because duty cycle is coded on 10 bits, the given value can't greater than 1024 If not active yet, calling this procedure will enable PWM
pwm1_set_dutycycle(byte in duty)
Sets dutycyle in low resolution mode. The 2 LSbits take their value from ccp1con_shadow, by default 0 This means if duty1 = 0, there's no pwm, if duty1 = 255, you're closed to (but not at) the maximum pwm
pwm1_on()
No documentation found
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
performs PWM operations on CCP2 The target must support this.
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
pwm2_set_percent_dutycycle(byte in percent)
pwm2_on()
pwm2_off()
pwm2_set_dutycycle(byte in duty)
pwm2_set_dutycycle_highres(word in duty)
var byte ccpr2l_shadow = 0
No documentation found
var byte ccp2con_shadow = 0
No documentation found
pwm2_set_percent_dutycycle(byte in percent)
This procedure set duty cycle using a percentage According to what has been computed by pwm_set_frequency(), it converts the duty percent to a value suitable for the selected pwm frequency.
pwm2_on()
No documentation found
pwm2_off()
No documentation found
pwm2_set_dutycycle(byte in duty)
Sets dutycyle in low resolution mode. The 2 LSbits take their value from ccp2con_shadow, by default 0 This means if duty2 = 0, there's no pwm, if duty2 = 255, you're closed to (but not at) the maximum pwm
pwm2_set_dutycycle_highres(word in duty)
sets dutycyle in high resolution mode the word passed to the procedure represents the high resolution value of the duty cycle: * duty2h<0:1> are the 2 LSbits * duty2h<2:9> are the 8 MSbits Because duty cycle is coded on 10 bits, the given value can't greater than 1024 If not active yet, calling this procedure will enable PWM
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
performs PWM operations on CCP3 The target must support this.
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
pwm3_on()
pwm3_set_dutycycle_highres(word in duty)
pwm3_set_percent_dutycycle(byte in percent)
pwm3_set_dutycycle(byte in duty)
pwm3_off()
var byte ccp3con_shadow = 0
No documentation found
var byte ccpr3l_shadow = 0
No documentation found
pwm3_on()
No documentation found
pwm3_set_dutycycle_highres(word in duty)
sets dutycyle in high resolution mode the word passed to the procedure represents the high resolution value of the duty cycle: * duty3h<0:1> are the 2 LSbits * duty3h<2:9> are the 8 MSbits Because duty cycle is coded on 10 bits, the given value can't greater than 1024 If not active yet, calling this procedure will enable PWM
pwm3_set_percent_dutycycle(byte in percent)
This procedure set duty cycle using a percentage According to what has been computed by pwm_set_frequency(), it converts the duty percent to a value suitable for the selected pwm frequency.
pwm3_set_dutycycle(byte in duty)
Sets dutycyle in low resolution mode. The 2 LSbits take their value from ccp3con_shadow, by default 0 This means if duty3 = 0, there's no pwm, if duty3 = 255, you're closed to (but not at) the maximum pwm
pwm3_off()
No documentation found
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
performs PWM operations on CCP4 The target must support this.
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
pwm4_off()
pwm4_set_percent_dutycycle(byte in percent)
pwm4_on()
pwm4_set_dutycycle_highres(word in duty)
pwm4_set_dutycycle(byte in duty)
var byte ccp4con_shadow = 0
No documentation found
var byte ccpr4l_shadow = 0
No documentation found
pwm4_off()
No documentation found
pwm4_set_percent_dutycycle(byte in percent)
This procedure set duty cycle using a percentage According to what has been computed by pwm_set_frequency(), it converts the duty percent to a value suitable for the selected pwm frequency.
pwm4_on()
No documentation found
pwm4_set_dutycycle_highres(word in duty)
sets dutycyle in high resolution mode the word passed to the procedure represents the high resolution value of the duty cycle: * duty4h<0:1> are the 2 LSbits * duty4h<2:9> are the 8 MSbits Because duty cycle is coded on 10 bits, the given value can't greater than 1024 If not active yet, calling this procedure will enable PWM
pwm4_set_dutycycle(byte in duty)
Sets dutycyle in low resolution mode. The 2 LSbits take their value from ccp4con_shadow, by default 0 This means if duty4 = 0, there's no pwm, if duty4 = 255, you're closed to (but not at) the maximum pwm
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
performs PWM operations on CCP5 The target must support this.
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
pwm5_set_dutycycle_highres(word in duty)
pwm5_set_dutycycle(byte in duty)
pwm5_on()
pwm5_off()
pwm5_set_percent_dutycycle(byte in percent)
var byte ccpr5l_shadow = 0
No documentation found
var byte ccp5con_shadow = 0
No documentation found
pwm5_set_dutycycle_highres(word in duty)
sets dutycyle in high resolution mode the word passed to the procedure represents the high resolution value of the duty cycle: * duty5h<0:1> are the 2 LSbits * duty5h<2:9> are the 8 MSbits Because duty cycle is coded on 10 bits, the given value can't greater than 1024 If not active yet, calling this procedure will enable PWM
pwm5_set_dutycycle(byte in duty)
Sets dutycyle in low resolution mode. The 2 LSbits take their value from ccp5con_shadow, by default 0 This means if duty5 = 0, there's no pwm, if duty5 = 255, you're closed to (but not at) the maximum pwm
pwm5_on()
No documentation found
pwm5_off()
No documentation found
pwm5_set_percent_dutycycle(byte in percent)
This procedure set duty cycle using a percentage According to what has been computed by pwm_set_frequency(), it converts the duty percent to a value suitable for the selected pwm frequency.
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | >=2.4g |
this lib handles generic operation on PWM, whatever the channel number, etc... It's aimed to be used with pwm_{register} lib (eg. pwm_ccp1.jal, ...)
this is a heavy refactoring of the original pwm_hardware.jal Stef's lib
No dependency found
var volatile dword _pr2_1
Stores computed PR2 value when prescaler value is 1 Used to compute accurate frequency
var volatile dword _pr2_16
Stores computed PR2 value when prescaler value is 16 Used to compute accurate frequency
var volatile dword _pr2_4
Stores computed PR2 value when prescaler value is 4 Used to compute accurate frequency
pwm_max_resolution(byte in prescaler)
initializes the PWM for high resolution (10 bits) and starts the PWM While setting high resolution, prescaler can be used to adjust frequency. The parameter corresponds to the prescaler value, and can be either: * 1 : high frequency * 4 : medium frequency * 16: low frequency Not all frequencies are available, you'll need the datasheet to actually compute the computed frequency according to the clock speed. FYI, here's a table showing frequency for common clock speed: ||*prescaler/clock* || *4MHz* || *8MHz* || *10MHz* || *20MHz* || || 1 || 3.90kHz || 7.81kHz || 9.77kHz || 19.43kHz || || 4 || 976Hz || 1.95kHz || 2.44kHz || 4.88kHz || || 16 || 244Hz || 488Hz || 610Hz || 1.22kHz ||
pwm_set_frequency(dword in freq)
Initializes the PWM for accurate frequency and starts the PWM
Author | Sebastien Lelong, Copyright (C) 2008-2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
just include this library if you want to use PWM. Why this one ? It uses to conditional compile to selectively include appropriate underlying pwm libs and number of PWM channels (up to 5), according to the PIC configuration. Ex: - 16f88 has 1 PWM channel: including pwm_hardware will configure PWM for 1 channel (using pwm_ccp1.jal) - 16f877 has 2 PWM channels: including pwm_hardware will configure PWM for 2 channels (using pwm_ccp1.jal and pwm_ccp2.jal) This is transparent for the user Please refer to pwm_common, pwm_ccp1, pwm_ccp2, ... and pwm_ccp5 documentation to understand how to use PWM.
this libraries uses conditional compilation. It requires at least jalv2 2.4i compiler version
No dependency found
16f877a | 16f877a_pwm_led.jal |
16f88 | 16f88_pwm_sound.jal |
16f88 | 16f88_ir_ranger_gp2d02.jal |
16f88 | 16f88_pwm_led_highres.jal |
16f88 | 16f88_pwm_led.jal |
Author | Joep Suijs, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
this library provides a (one) byte fifo queue. This queue is interrupt-safe in the sense that you can write to the queue from the interrupt and read from the main program or vice versa without special precautions. Reading (or writing) from both interrupt and main program might not work properly. The basic interface is pseudo var: queue01 = x -- put x into queue; block if queue is full x = queue01 -- read x from queue; block if queue is empty non-blocking access to the same queue is provided by queue01_nb_put() and queue01_nb_get() other methods: queue01_clear() -- clear queue (makes queue empty) queue01_empty() -- returns true if queue is emtpy
No dependency found
var volatile byte queue01_in_pointer = 0 ; wijst naar vrije locatie
var volatile byte queue01_data[queue01_size + 1]
var volatile byte queue01_out_pointer = 0 ; wijst naar databyte
queue01_nb_put(byte in v) return bit
queue01'get() return byte
queue01_nb'get() return byte
queue01_empty() return bit
queue01_nb_get(byte out v) return bit
var volatile byte queue01_in_pointer = 0 ; wijst naar vrije locatie
No documentation found
var volatile byte queue01_data[queue01_size + 1]
queue vars
var volatile byte queue01_out_pointer = 0 ; wijst naar databyte
No documentation found
queue01_nb'put(byte in v)
queue01_nb'put - put one byte into queue (non-blocking)
queue01'put(byte in v)
queue01'put - put one byte into queue When the queue is full, it waits until a byte is removed from the queue.
queue01_clear()
No documentation found
queue01_nb_put(byte in v) return bit
queue01_nb_put - put one byte into queue (non-blocking) return: true when the byte is put into the queue false when the queue is full (byte is not put in queue)
queue01'get() return byte
queue01'get - get one byte from queue returns byte from queue. When the queue is empty, it waits until a byte is put into the queue.
queue01_nb'get() return byte
queue01_nb'get - get one byte from queue (non-blocking) returns byte from queue, 0 if queue empty
queue01_empty() return bit
No documentation found
queue01_nb_get(byte out v) return bit
queue01_nb_get - get one byte from queue (non-blocking) The byte read is put into v (calling param) returns: true when we read a byte from the queue false when the queue is empty (byte is not read from queue)
16f877a | 16f877a_i2c_hw_slave_eeprom_simulator.jal |
16f88 | 16f88_i2c_hw_slave_eeprom_simulator.jal |
Author | Joep Suijs, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4i |
this library provides a (decent) random function. The formula is provided by *the* George Marsaglia. (see http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2008-03/msg03691.html) /* initialize with any 32-bit seed x and any 32-bit y not 0 */ static unsigned long x=2282008, y=362436069; #define sK ( x=69069*x+123, y^=y<<13, y^=y>>17, y^=y<<5, x+y ) function random_byte returns an 8-bit random number function random_word returns a 16-bit random number functon dice returns a number from 1 to 6 Note: this library will recreate the same sequence. If this is undesired, assign a different (non-zero!) startup-value to -rndx and/or _rndx at startup. Note2: If you don't care about random quality and want to save a few processor cycles or memory bytes, define random_downgrade to select a basic random algorithm.
Interface Copyright (C) 2005 Stef Mientki
No dependency found
var byte nr
No documentation found
var volatile dword _rndx = 2282008
No documentation found
dice() return byte
dice - return a random number in the range [1..6]
random_word() return word
random_word - return a 16-bit random number
random_byte() return byte
random_byte - return an 8-bit random number
16f648a | 16f648a_random.jal |
16f877a | 16f877a_random.jal |
16f88 | 16f88_random.jal |
18f4550 | 18f4550_random.jal |
Author | Eur van Andel, Copyright (c) 2003..2008, all rights reserved. |
Adapted-by | |
Compiler | >=2.4h |
This Interrupt Service Routine updates the variable seconds about once per second. The precision is 0.2 ppm, the accuracy depends on the Xtal used.
http://www.romanblack.com/one_sec.htm, http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
This is the Bresenham Line Algorithm, invented at IBM in 1962, which gets an accurate end result by summing the small errors resulting of taking discrete steps and correcting when the error gets too large. This means that individual second lengths may show some jitter, but that long-term timekeeping is accurate. Original assembler by Roman Black.
No dependency found
var volatile byte seconds -- updated by ISR
const mid = 0x4B
var volatile byte bres_lo = lo
const lo = 0x40 -- ideally modified in timeset too, to adjust clock
var volatile byte bres_hi = hi
const hi = 0x4C -- 2 000 000 for 20 MHz xtal and prescaler = 4
var volatile byte bres_mid = mid
var volatile byte seconds -- updated by ISR
No documentation found
const mid = 0x4B
No documentation found
var volatile byte bres_lo = lo
No documentation found
const lo = 0x40 -- ideally modified in timeset too, to adjust clock
No documentation found
var volatile byte bres_hi = hi
No documentation found
const hi = 0x4C -- 2 000 000 for 20 MHz xtal and prescaler = 4
No documentation found
var volatile byte bres_mid = mid
No documentation found
RTC()
No documentation found
16f876a | 16f876a_rtc_lcd.jal |
16f877a | 16f877a_rtc_lcd.jal |
Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4g |
USART hardware control. Routines for sending and receiving through the PIC-usart, both asynchrone and synchrone are supported. Baudrate can simply be set through a human constant, because the baudrate depending registers are calculated by this unit. Baudrate is calculated, starting at the high baudrate flag, which will ensure the highest possible accuracy.
var volatile bit serial_hw_data_available is PIR1_RCIF
var volatile bit serial_hw_data_ready is PIR1_TXIF
serial_hw_data'put(byte in data)
serial_hw_init()
serial_hw_write_word(word in data)
serial_hw_write(byte in data)
serial_hw_data_raw'put(byte in data)
serial_hw_enable()
serial_hw_disable()
serial_hw_read(byte out data) return bit
serial_hw_data'get() return byte
serial_hw_data_raw'get() return byte
var volatile bit serial_hw_data_available is PIR1_RCIF
some variables made available under a general (pic-independant) name
var volatile bit serial_hw_data_ready is PIR1_TXIF
No documentation found
serial_hw_data'put(byte in data)
Here Serial read and write are definied as pseudo variables so you use them as normal vars, like * wait for character being received, * then echo the inverted character {{{ serial_hw_data = ! serial_hw_data }}} these procedures will wait till they can perform their action therefore it's better to use to following construct {{{ if charater received, echo the inverted character if serial_hw_data_available then serial_hw_data = ! serial_hw_data end if do other things }}}
serial_hw_init()
Initializes the serial port, calculates baudrate registers.
serial_hw_write_word(word in data)
like Serial_H_write, but then with a word as input The MSB is outputed first
serial_hw_write(byte in data)
serial_hw_write - write char to serial port, blocking Asynchronuous serial send routine, using the TX pin Sends byte X (8 bit with no parity) to the serial port First checks (and waits if necessary) if transmit buffer is empty
serial_hw_data_raw'put(byte in data)
These are real raw procedures, declared as pseudo variables the user is totally responsible for testing the transmit/receive flag before using these functions
serial_hw_enable()
Enables USART
serial_hw_disable()
Disables USART so ports can be used (temporary) for other purposes. USART can be enabled again by calling serial_hw_enable()
serial_hw_read(byte out data) return bit
serial_hw_read - read char if available (non-blocking) Returns true if a character was received, otherwise returns false. Overrun error flag is cleared.
serial_hw_data'get() return byte
No documentation found
serial_hw_data_raw'get() return byte
No documentation found
_serial_hw_read(byte out data) return bit
_serial_hw_read - internal use only! (using this inline function for serial_hw_data'get saves a stack level) Returns true if a character was received, otherwise returns false. Overrun error flag is cleared.
Author | Rob Hamerling, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | =2.4h |
Serial communications: - receive and transmit data transfer is interrupt driven - receive and transmit data transfer uses circular buffers - automatic CTS flow control with spare free space for FiFo buffer
- For data transmit and receive the pins TX and RX are used automatically, these have not to be assigned by the application. - The selection of the CTS pin above is an example, any other pin which is configurable for output can be used. - When CTS flow control is not desired then assign serial_ctsinv to a dummy bit, for example: var bit dummy_cts_bit var bit serial_ctsinv is dummy_cts_bit - The serial_overflow_discard flag may be dynamically changed (depending on how important the data is for the receiving party). - Do not touch the following interrupt bits: TXIE, RCIE, PEIE and GIE
var byte _serial_offsetxmthead -- offset next byte from appl
var byte _serial_rcvbuf[SERIAL_RCVBUFSIZE] -- circular input buffer
var byte _serial_offsetxmttail -- offset next byte to port
var byte _serial_offsetrcvhead -- offset next byte from port
var byte _serial_offsetrcvtail -- offset next byte to appl
var bit serial_send_success -- serial_send_success is used internally
var byte _serial_xmtbuf[SERIAL_XMTBUFSIZE] -- circular output buffer
serial_hw_read(byte out data) return bit
serial_hw_data'get() return byte
serial_receive_byte(byte out data) return bit
serial_send_byte(byte in data) return byte
var byte _serial_offsetxmthead -- offset next byte from appl
variable keeping track of next free position in transmit buffer
var byte _serial_rcvbuf[SERIAL_RCVBUFSIZE] -- circular input buffer
Local circular receive buffer
var byte _serial_offsetxmttail -- offset next byte to port
variable keeping track of next byte to be transmitted by interrupt handler
var byte _serial_offsetrcvhead -- offset next byte from port
variable keeping track of next free byte in receive buffer
var byte _serial_offsetrcvtail -- offset next byte to appl
variable keeping track of next byte available to application program
var bit serial_send_success -- serial_send_success is used internally
Flag indicating if transmission was successful
var byte _serial_xmtbuf[SERIAL_XMTBUFSIZE] -- circular output buffer
Local circular transmit buffer
serial_init()
Deprecated
serial_hw_data'put(byte in data)
Transmit byte
serial_hw_init()
serial_init - procedure to initialize library functionality
serial_hw_write(byte in data)
Transmit byte
_serial_transmit_interrupt_handler()
USART serial transmit interrupt handler
_serial_receive_interrupt_handler()
USART serial receive interrupt handler notes: - Sets CTS low when receive buffer has less thanbytes free space.
serial_hw_read(byte out data) return bit
Return byte (if any) from circular receive buffer for UART input: nothing output: received byte (if any) returns: TRUE when byte returned FALSE if no byte available notes: - Sets CTS high when receive buffer has more thanbytes free space after delivering byte to caller.
serial_hw_data'get() return byte
Return next received byte
serial_receive_byte(byte out data) return bit
Deprecated
serial_send_byte(byte in data) return byte
Put a single byte in circular transmit buffer for UART input: byte to transmit returns: transmitted byte (or 0x00 when data discarded) notes: - Activates transmit interrupt handler when data buffered - When buffer full act as indicated in 'serial_overflow_discard' * TRUE: discard data (and return 0x00 as data byte) * FALSE: wait for free buffer space (returns only after data has been stored in buffer)
Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4g |
software RS232 library Library supports software RS232 send and receive procedure on any IO-pin. Both the inverted and non-inverted routines are available, so it should fit any hardware. Baudrate can be set between 110 and 230_400 (for 20 Mhz Xtal), for lower Xtal frequencies the maximum baudrate will be equally lower. Baudrates are optimized, so even the high baudrates shouldn't be a problem (my [Stef] standard = 115_200 Baud, which has never given me any problems). Interrupts should be disabled during transmissions. Transmission parameters are 8 databits, 2 stopbits, no parity, no handshake.
No dependency found
const OL_TX = ( _NINSTR / ( 3 * 255 )) + 1
var byte ilval0
const _NINSTR2 = 5 + ( _NINSTR / 2)
var byte ilval
var byte olval
const _NINSTR = target_clock / (4 * serial_sw_baudrate)
const _IL_TX = ( ( _NINSTR - ( 4 * OL_TX ) ) - 16 ) / ( 3 * OL_TX )
var byte IL_TX = _IL_TX
serial_sw_data'put(byte in data)
serial_sw_write(byte in data)
serial_sw_init()
serial_sw_read_wait(byte out data)
const OL_TX = ( _NINSTR / ( 3 * 255 )) + 1
No documentation found
var byte ilval0
No documentation found
const _NINSTR2 = 5 + ( _NINSTR / 2)
No documentation found
var byte ilval
No documentation found
var byte olval
No documentation found
const _NINSTR = target_clock / (4 * serial_sw_baudrate)
No documentation found
const _IL_TX = ( ( _NINSTR - ( 4 * OL_TX ) ) - 16 ) / ( 3 * OL_TX )
No documentation found
var byte IL_TX = _IL_TX
No documentation found
serial_sw_data'put(byte in data)
Here the serial_sw_write procedure is declared as a pseudo variable so you can use it in the following way: {{{ serial_sw_write = 0x33 }}}
serial_sw_write(byte in data)
Waits untill a character is received. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.
serial_sw_init()
No documentation found
serial_sw_read_wait(byte out data)
Waits untill a character is received. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.
serial_sw_data'get() return byte
Here the serial_sw_read_wait procedure is declared as a pseudo variable so you can use it in the following way {{{ Data = serial_sw_write }}}
serial_sw_read(byte out data) return bit
Waits untill a character is received or time out is reached. Interrupts will be disabled during this routine, but restored afterwards. Also here the code is doubled (inverting and non-inverting) and selection is done by a compiler-directive.
16f88 | 16f88_serial_sw_echo.jal |
Author | Eur van Andel, eur@fiwihex.nl Copyright (c) 2008 |
Adapted-by | |
Compiler | =2.4h |
this library reads the TC77 temperature sensor from Microchip. The TC77 has a 12-bit plus sign temperature resolution of 0.0625°C per Least Significant Bit (LSb). It works via the SPI protocol Specs: 1C (max.) accuracy from +25°C to +65C, 2C (max.) accuracy from -40°C to +85C 3C (max.) accuracy from -55°C to +125C 2.7V to 5.5V Operating Range, Low Power: 250uA (typ.) Continuous Conversion Mode, 0.1uA (typ.) Shutdown Mode -------- I have several years of experience with hundreds of these sensors. They work very well: fast, good accuracy, good repeatability. If they have an offset, it can easily be calibrated in software. The hard part of using this sensor is gettting it watertigtht. It is SMD, so it needs a PCB, and a cable. Dipping in resin or shrinking in glue-covered shrinktube works. The SPI protocol is bit-banged here and can be used with any pins. Clock data in on rising edge of clock, program must pull CS low. This allows for multiple TC77s on the same 2-wire databus. Put a 100nF decoupling capacitor close the the TC77. If you don't, you WILL get weird data. This library assumes two pins: global bit SCK, wired to SCK of device and global bit SIO,wired to SIO of device. SCK should be output, SIO input. Writing the status_word is not supported here.
No dependency found
tc77_read_celsius_sdword(sdword out temperature)
tc77_read_raw(word out raw)
tc77_read_celsius_sword(sword out temperature)
tc77_read_celsius_sbyte(sbyte out temperature)
tc77_read_celsius_sdword(sdword out temperature)
read celsius temperature of TC77 output in one sdword with 4 digits, so T = xxx.xxxx C last bit is 0.0001C , range is -40C ... +125C
tc77_read_raw(word out raw)
get raw temperature of TC77 output in word, right justified
tc77_read_celsius_sword(sword out temperature)
read celsius temperature of TC77 output in one sword with 2 digits, so T = xxx.xx C last bit is 0.01C , range is -40C ... +125C best procedure if you want to display C in 0.1 accurate take care of rounding during printing
tc77_read_celsius_sbyte(sbyte out temperature)
read celsius temperature of TC77 output in one sbyte with zero digits, so T = +/- xxx C last bit is 1C, range is -40C ... +125C no rounding, celsius fraction is chopped
16f876a | 16f876a_tc77.jal |
Author | Joep Suijs, Copyright (C) 2008 Joep Suijs |
Adapted-by | Rob Hamerling |
Compiler | >=2.4j |
Fixed interval isr with support for non-blocking delays.
No dependency found
var byte timer0_load
No documentation found
var word isr_countdown[DELAY_SLOTS]
No documentation found
var word internal_isr_counter
No documentation found
timer0_isr_init()
No documentation found
set_delay(byte in slot, word in ticks)
No documentation found
ISR()
No documentation found
isr_counter'get() return word
No documentation found
check_delay(byte in slot) return bit
No documentation found
16f648a | 16f648a_timer0_interval.jal |
Author | Stef Mientki Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Joep Suijs |
Compiler | >=2.4g |
USART common functions This file provides common functions to other libraries. Baudrate can simply be set through a human constant, because the baudrate depending registers are calculated by this unit. Baudrate is calculated, starting at the high baudrate flag, which will ensure the highest possible accuracy.
No dependency found
_calculate_and_set_baudrate()
internal function, calculates and sets baudrate divider and stores it in the appropiate register. the high-speed / low-speed bit is not stored but returned as the result Special attention is payed to the highest and lowest baudrates, a deviation of 5% is accepted in these cases Asynchronous baudrate settings (see also page 74/75 of DS40300B): {{{ if TXSTA_BRGH = 0 (low speed) SPBRG = ( Fosc / ( 64 * Baudrate ) ) -1 if TXSTA_BRGH = 1 (high speed) SPBRG = ( Fosc / ( 16 * Baudrate ) ) -1 }}} Synchronous baudrate settings: * TXSTA_BRGH = 0 (low speed) * SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
Author | Albert Faber, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | - |
Compiler | >=2.4j |
Constants for configurting the USB interface
http://www.usb.org for USB specifications
No dependency found
var volatile bit EP2CONDIS at UEP2:3
var volatile byte usb_bd5in_cnt at usb_bd5in[1]
var volatile byte usb_bd5in_stat at usb_bd5in[0]
const byte USB_REQUEST_REQ_SYNCH_FRAME = 0x0c
const byte USB_DT_DEBUG = 0x0a
var volatile word usb_bd5out_addr at usb_bd5out[2]
var byte usb_delivery_buffer_size
var volatile byte usb_bd4in[4] at ( USB_BASE_ADDRESS + 0x0024 )
var volatile bit EP3CONDIS at UEP3:3
const byte USB_DT_OTG = 0x09
const byte USB_BD_CNT_IDX = 0x01
var volatile byte usb_sdp_request at usb_sdp_loc + 1
var volatile byte usb_bd3in_cnt at usb_bd3in[1]
const byte USB_CM_CTRL_WRITE_DATA_STAGE_CLASS = 2 -- Device receiving data during the data stage destined for the class
var byte usb_delivery_bytes_max_send
var byte usb_control_mode
var volatile bit EP3OUTEN at UEP3:2
const byte USB_REQUEST_SET_CONFIGURATION = 0x09
const byte USB_STATE_CONFIGURED = 3 -- USB device is completely configured and ready to rock and roll
const byte USB_HID_PROTOCOL_NONE = 0x00
var volatile byte usb_bd2out[4] at ( USB_BASE_ADDRESS + 0x0010 )
var volatile byte usb_bd1in_addrl at usb_bd1in[2]
const byte USB_PID_NYET = 0b00000110
const byte USB_REQUEST_CLEAR_FEATURE = 0x01
const word USB_IN_DELIVERY_BUFFER_LOC = ( USB_BASE_ADDRESS + 0x0078 )
var volatile byte usb_bd0out_addrl at usb_bd0out[2]
var volatile byte usb_bd5in_addrh at usb_bd5in[3]
var volatile bit EP2HSHK at UEP2:4
const byte USB_EXTERNAL_TRANSCEIVER = 0x08
var volatile byte usb_bd0out_addrh at usb_bd0out[3]
const byte USB_CM_CTRL_WRITE_DATA_STAGE = 1 -- Device receiving data during the data stage
const byte USB_REQUEST_SET_ADDRESS = 0x05
const byte USB_DT_INTERFACE_POWER = 0x08
const byte USB_HID_PROTOCOL_KEYBOARD = 0x01
const byte USB_EP_OUT = 0x0C -- Cfg OUT only pipe for this ep
var volatile byte usb_bd5out_cnt at usb_bd5out[1]
const byte USB_PING_PONG__ALL_BUT_EP0 = 0x03 -- 0b11
var volatile byte usb_bd1out_addrh at usb_bd1out[3]
const byte USB_PID_MDATA = 0b00001111
const byte USB_DT_CS_INTERFACE = 0x24
const byte USB_CM_CTRL_WRITE_SENDING_STATUS = 6 -- Device is sending status after receiving data
const byte USB_REQUEST_SET_INTERFACE = 0x0b
const byte USB_EPT_BULK = 0x02 -- Bulk Transfer
var volatile byte usb_bd3out_stat at usb_bd3out[0]
var volatile byte usb_bd2in_cnt at usb_bd2in[1]
var volatile word usb_bd1out_addr at usb_bd1out[2]
var volatile byte usb_bd5in_addrl at usb_bd5in[2]
const byte USB_ABSTRACT_CONTROL_MODEL = 0x02
var volatile word usb_sdp_length at usb_sdp_loc + 6
const byte USB_BDSTATUS_BC9 = 1 -- bit 9 of buffer count
const byte USB_DT_HID_REPORT = 0x22
const USB_REQUEST_TYPE0_BIT = 5 -- 01= Request for a specific class
var byte usb_status
const byte USB_BD_ADDRL_IDX = 0x03
var volatile byte usb_bd5in[4] at ( USB_BASE_ADDRESS + 0x002C )
const byte USB_STATE_DEFAULT = 1 -- USB device is now negotiating
const byte USB_PID_IN = 0b00001001
const byte USB_PID_DATA1 = 0b00001011
var volatile byte usb_bd1out_cnt at usb_bd1out[1]
var volatile byte usb_bd1out[4] at ( USB_BASE_ADDRESS + 0x0008 )
var volatile bit EP1CONDIS at UEP1:3
const byte USB_BDSTATUS_KEN = 5 -- 1 USB will keep buffer indefinately, 0 USB will hand back buffer
const byte USB_STATE_POWERED = 0 -- USB device is powered up, ready to start negotiating
var volatile word usb_bd3out_addr at usb_bd3out[2]
var volatile byte usb_bd4out_addrh at usb_bd4out[3]
const byte USB_DT_HID = 0x21
const byte USB_INTERNAL_TRANSCEIVER = 0x00
var byte usb_delivery_bytes_to_send
var volatile byte usb_bd0in_addrh at usb_bd0in[3]
var volatile byte usb_bd1out_stat at usb_bd1out[0]
const byte USB_COMM_INTF = 0x02
var volatile byte usb_bd0in_stat at usb_bd0in[0]
var volatile byte usb_bd4out_cnt at usb_bd4out[1]
var volatile byte usb_bd1in[4] at ( USB_BASE_ADDRESS + 0x000C )
var volatile word usb_bd0in_addr at usb_bd0in[2]
const byte USB_EP_OUT_IN = 0x0E -- Cfg both OUT & IN pipes for this ep
var volatile byte usb_bd3out_cnt at usb_bd3out[1]
var volatile byte usb_bd4out_stat at usb_bd4out[0]
var volatile word usb_sdp_value at usb_sdp_loc + 2
const byte USB_VENDOR_INTF = 0xFF
var volatile byte usb_bd2in_addrl at usb_bd2in[2]
var volatile byte usb_bd2in_addrh at usb_bd2in[3]
const byte USB_DT_INTERFACE = 0x04
var volatile byte usb_bd3in_addrh at usb_bd3in[3]
var volatile word usb_bd1in_addr at usb_bd1in[2]
const byte USB_BDSTATUS_BSTALL = 2 -- 1 buffer stall enabled, 0 buffer stall disabled
const byte USB_CM_CTRL_READ_AWAITING_STATUS = 5 -- Device is awaiting reception of status after sending data
var volatile byte usb_bd_array[ 255 ] at ( USB_BASE_ADDRESS + 0x0000 )
const byte USB_EPT_ISO = 0x01 -- Isochronous Transfer
var volatile bit EP3STALL at UEP3:0
const byte USB_BDSTATUS_UOWN = 7 -- 0 if uC owns buffer
var volatile bit EP3HSHK at UEP3:4
var volatile byte usb_bd1in_addrh at usb_bd1in[3]
var volatile byte usb_bd5out_stat at usb_bd5out[0]
const byte USB_V25TER = 0x01 -- Common AT commands ("Hayes(TM)")
var volatile byte usb_bd3in_addrl at usb_bd3in[2]
const byte USB_DT_INTERFACE_ASSOC = 0x0b
const byte USB_REQUEST_GET_DESCRIPTOR = 0x06
var volatile bit EP3INEN at UEP3:1
var byte usb_delivery_buffer[ 8 ] at USB_IN_DELIVERY_BUFFER_LOC
const byte USB_HID_INTF = 0x03
var volatile word usb_bd2out_addr at usb_bd2out[2]
const byte USB_DT_DEVICE_QUALIFIER = 0x06
const byte USB_PID_DATA2 = 0b00000111
var volatile word usb_bd3in_addr at usb_bd3in[2]
var volatile byte usb_bd4in_addrl at usb_bd4in[2]
const byte USB_STATUS_SET_ADDRESS = 1
var volatile bit EP2INEN at UEP2:1
var volatile byte usb_bd2out_stat at usb_bd2out[0]
const byte USB_BDSTATUS_BC8 = 0 -- bit 8 of buffer count
const byte USB_LOW_SPEED = 0x00
var volatile byte usb_sdp[8] at usb_sdp_loc
var volatile bit EP1HSHK at UEP1:4
const byte USB_BDSTATUS_INCDIS = 4 -- 1 Address increment disabled (for SPP), 0 address increment enabled
const bit USB_SELF_POWERED = 1
const byte USB_EP_CTRL = 0x06 -- Cfg Control pipe for this ep
const byte USB_STATE_ADDRESS = 2 -- USB device now has an address
const byte USB_BD_STAT_IDX = 0x00
var volatile byte usb_bd4out[4] at ( USB_BASE_ADDRESS + 0x0020 )
const byte USB_STATUS_IDLE = 0
var volatile byte usb_bd0out[4] at ( USB_BASE_ADDRESS + 0x0000 )
var volatile bit EP2STALL at UEP2:0
var volatile byte usb_bd0out_cnt at usb_bd0out[1]
var volatile word usb_bd4out_addr at usb_bd4out[2]
var volatile byte usb_bd2out_cnt at usb_bd2out[1]
var volatile bit EP2OUTEN at UEP2:2
var volatile byte usb_bd5out_addrh at usb_bd5out[3]
const byte USB_BD_ADDRH_IDX = 0x02
var volatile word usb_bd2in_addr at usb_bd2in[2]
var volatile byte usb_bd3in_stat at usb_bd3in[0]
const byte USB_CDC_DEVICE = 0x02
const byte USB_PID_OUT = 0b00000001
const byte USB_BDSTATUS_DTSEN = 3 -- 1 data toggle sync on, 0 data toggle sync off
const byte USB_PULLUP_DISABLED = 0x00
const byte USB_EPT_CTRL = 0x00 -- Control Transfer
const byte USB_PID_DATA0 = 0b00000011
var volatile byte usb_bd1in_stat at usb_bd1in[0]
const byte USB_REQUEST_SET_DESCRIPTOR = 0x07
var volatile byte usb_bd3out_addrl at usb_bd3out[2]
const byte USB_REQUEST_GET_INTERFACE = 0x0a
var volatile byte usb_bd3out_addrh at usb_bd3out[3]
const byte USB_REQUEST_SET_FEATURE = 0x03
var byte usb_address
var volatile byte usb_bd2out_addrh at usb_bd2out[3]
var volatile byte usb_bd1out_addrl at usb_bd1out[2]
const byte USB_PID_STALL = 0b00001110
var volatile byte usb_bd2in[4] at ( USB_BASE_ADDRESS + 0x0014 )
var volatile byte usb_bd4in_cnt at usb_bd4in[1]
var volatile bit EP1INEN at UEP1:1
var volatile byte usb_bd4in_stat at usb_bd4in[0]
var volatile byte usb_bd0in[4] at ( USB_BASE_ADDRESS + 0x0004 )
var volatile word usb_bd4in_addr at usb_bd4in[2]
const USB_DEVICE_DESCRIPTOR_SIZE = 18
var volatile byte usb_bd5out_addrl at usb_bd5out[2]
const byte USB_PULLUP_ENABLE = 0x10
const byte USB_DT_CONFIGURATION = 0x02
var volatile byte usb_bd0out_stat at usb_bd0out[0]
const byte USB_DT_OTHER_SPEED_CONFIG = 0x07
var volatile word usb_bd0out_addr at usb_bd0out[2]
const byte USB_FULL_SPEED = 0x04
const byte USB_EPT_INT = 0x03 -- Interrupt Transfer
const word usb_sdp_loc = ( USB_BASE_ADDRESS + 0x00F8 )
var volatile byte usb_bd3out[4] at ( USB_BASE_ADDRESS + 0x0018 )
var volatile byte usb_bd4out_addrl at usb_bd4out[2]
var volatile byte usb_bd5out[4] at ( USB_BASE_ADDRESS + 0x0028 )
var volatile byte usb_bd2in_stat at usb_bd2in[0]
var byte usb_delivery_bytes_sent
const byte USB_PID_SETUP = 0b00001101
var volatile byte usb_bd1in_cnt at usb_bd1in[1]
var volatile byte usb_sdp_request_type at usb_sdp_loc
const byte USB_DT_STRING = 0x03
const byte USB_BOOT_INTF_SUBCLASS = 0x01
var volatile byte usb_bd4in_addrh at usb_bd4in[3]
const byte USB_HID_PROTOCOL_MOUSE = 0x02
var volatile word usb_bd5in_addr at usb_bd5in[2]
var volatile bit EP1STALL at UEP1:0
const byte USB_EP_IN = 0x0A -- Cfg IN only pipe for this ep
var volatile byte usb_bd0in_cnt at usb_bd0in[1]
const USB_REQUEST_TYPE1_BIT = 6 -- 00= USB standard request
const byte USB_PING_PONG__FULL_PING_PONG = 0x02 -- 0b10
var volatile word usb_sdp_index at usb_sdp_loc + 4
const USB_DATA_STAGE_DIR_BIT = 7
const byte USB_PID_SOF = 0b00000101
const byte USB_CM_CTRL_READ_DATA_STAGE = 3 -- Device sending data during the data stage
var volatile byte usb_bd3in[4] at ( USB_BASE_ADDRESS + 0x001C )
const byte USB_HSHK_EN = 0x10 -- Enable handshake packet
const byte USB_PING_PONG__NO_PING_PONG = 0x00 -- 0b00
const byte USB_PING_PONG__EP0_OUT_ONLY = 0x01 -- 0b01
const byte USB_CM_IDLE = 0 -- No control transfer taking place
const byte USB_HIGHEST_EP = 3
const byte USB_BDSTATUS_DTS = 6 -- 1 data 1 packet, 0 data 0 packet
var byte usb_state = USB_STATE_POWERED
var volatile byte usb_bd2out_addrl at usb_bd2out[2]
var volatile bit EP1OUTEN at UEP1:2
const byte USB_REQUEST_GET_STATUS = 0x00
const byte USB_CM_CTRL_READ_DATA_STAGE_CLASS = 4 -- Device class is sending data during the data stage
const byte USB_DT_ENDPOINT = 0x05
const byte USB_PID_ACK = 0b00000010
var volatile byte usb_bd0in_addrl at usb_bd0in[2]
const byte USB_PID_NAK = 0b00001010
const byte USB_REQUEST_GET_CONFIGURATION = 0x08
const byte USB_DT_DEVICE = 0x01
var volatile bit EP2CONDIS at UEP2:3
No documentation found
var volatile byte usb_bd5in_cnt at usb_bd5in[1]
No documentation found
var volatile byte usb_bd5in_stat at usb_bd5in[0]
No documentation found
const byte USB_REQUEST_REQ_SYNCH_FRAME = 0x0c
No documentation found
const byte USB_DT_DEBUG = 0x0a
No documentation found
var volatile word usb_bd5out_addr at usb_bd5out[2]
No documentation found
var byte usb_delivery_buffer_size
No documentation found
var volatile byte usb_bd4in[4] at ( USB_BASE_ADDRESS + 0x0024 )
No documentation found
var volatile bit EP3CONDIS at UEP3:3
No documentation found
const byte USB_DT_OTG = 0x09
No documentation found
const byte USB_BD_CNT_IDX = 0x01
No documentation found
var volatile byte usb_sdp_request at usb_sdp_loc + 1
No documentation found
var volatile byte usb_bd3in_cnt at usb_bd3in[1]
No documentation found
const byte USB_CM_CTRL_WRITE_DATA_STAGE_CLASS = 2 -- Device receiving data during the data stage destined for the class
No documentation found
var byte usb_delivery_bytes_max_send
No documentation found
var byte usb_control_mode
No documentation found
var volatile bit EP3OUTEN at UEP3:2
No documentation found
const byte USB_REQUEST_SET_CONFIGURATION = 0x09
No documentation found
const byte USB_STATE_CONFIGURED = 3 -- USB device is completely configured and ready to rock and roll
No documentation found
const byte USB_HID_PROTOCOL_NONE = 0x00
HID Interface Class Protocol Codes
var volatile byte usb_bd2out[4] at ( USB_BASE_ADDRESS + 0x0010 )
No documentation found
var volatile byte usb_bd1in_addrl at usb_bd1in[2]
No documentation found
const byte USB_PID_NYET = 0b00000110
No documentation found
const byte USB_REQUEST_CLEAR_FEATURE = 0x01
No documentation found
const word USB_IN_DELIVERY_BUFFER_LOC = ( USB_BASE_ADDRESS + 0x0078 )
No documentation found
var volatile byte usb_bd0out_addrl at usb_bd0out[2]
No documentation found
var volatile byte usb_bd5in_addrh at usb_bd5in[3]
No documentation found
var volatile bit EP2HSHK at UEP2:4
No documentation found
const byte USB_EXTERNAL_TRANSCEIVER = 0x08
No documentation found
var volatile byte usb_bd0out_addrh at usb_bd0out[3]
No documentation found
const byte USB_CM_CTRL_WRITE_DATA_STAGE = 1 -- Device receiving data during the data stage
No documentation found
const byte USB_REQUEST_SET_ADDRESS = 0x05
No documentation found
const byte USB_DT_INTERFACE_POWER = 0x08
No documentation found
const byte USB_HID_PROTOCOL_KEYBOARD = 0x01
No documentation found
const byte USB_EP_OUT = 0x0C -- Cfg OUT only pipe for this ep
No documentation found
var volatile byte usb_bd5out_cnt at usb_bd5out[1]
No documentation found
const byte USB_PING_PONG__ALL_BUT_EP0 = 0x03 -- 0b11
No documentation found
var volatile byte usb_bd1out_addrh at usb_bd1out[3]
No documentation found
const byte USB_PID_MDATA = 0b00001111
No documentation found
const byte USB_DT_CS_INTERFACE = 0x24
No documentation found
const byte USB_CM_CTRL_WRITE_SENDING_STATUS = 6 -- Device is sending status after receiving data
No documentation found
const byte USB_REQUEST_SET_INTERFACE = 0x0b
No documentation found
const byte USB_EPT_BULK = 0x02 -- Bulk Transfer
No documentation found
var volatile byte usb_bd3out_stat at usb_bd3out[0]
No documentation found
var volatile byte usb_bd2in_cnt at usb_bd2in[1]
No documentation found
var volatile word usb_bd1out_addr at usb_bd1out[2]
No documentation found
var volatile byte usb_bd5in_addrl at usb_bd5in[2]
No documentation found
const byte USB_ABSTRACT_CONTROL_MODEL = 0x02
Communication Interface Class SubClass Codes
var volatile word usb_sdp_length at usb_sdp_loc + 6
No documentation found
const byte USB_BDSTATUS_BC9 = 1 -- bit 9 of buffer count
No documentation found
const byte USB_DT_HID_REPORT = 0x22
No documentation found
const USB_REQUEST_TYPE0_BIT = 5 -- 01= Request for a specific class
No documentation found
var byte usb_status
No documentation found
const byte USB_BD_ADDRL_IDX = 0x03
No documentation found
var volatile byte usb_bd5in[4] at ( USB_BASE_ADDRESS + 0x002C )
No documentation found
const byte USB_STATE_DEFAULT = 1 -- USB device is now negotiating
No documentation found
const byte USB_PID_IN = 0b00001001
No documentation found
const byte USB_PID_DATA1 = 0b00001011
No documentation found
var volatile byte usb_bd1out_cnt at usb_bd1out[1]
No documentation found
var volatile byte usb_bd1out[4] at ( USB_BASE_ADDRESS + 0x0008 )
No documentation found
var volatile bit EP1CONDIS at UEP1:3
No documentation found
const byte USB_BDSTATUS_KEN = 5 -- 1 USB will keep buffer indefinately, 0 USB will hand back buffer
No documentation found
const byte USB_STATE_POWERED = 0 -- USB device is powered up, ready to start negotiating
USB STATE
var volatile word usb_bd3out_addr at usb_bd3out[2]
No documentation found
var volatile byte usb_bd4out_addrh at usb_bd4out[3]
No documentation found
const byte USB_DT_HID = 0x21
No documentation found
const byte USB_INTERNAL_TRANSCEIVER = 0x00
No documentation found
var byte usb_delivery_bytes_to_send
No documentation found
var volatile byte usb_bd0in_addrh at usb_bd0in[3]
No documentation found
var volatile byte usb_bd1out_stat at usb_bd1out[0]
No documentation found
const byte USB_COMM_INTF = 0x02
Communication Interface Class Code
var volatile byte usb_bd0in_stat at usb_bd0in[0]
No documentation found
var volatile byte usb_bd4out_cnt at usb_bd4out[1]
No documentation found
var volatile byte usb_bd1in[4] at ( USB_BASE_ADDRESS + 0x000C )
No documentation found
var volatile word usb_bd0in_addr at usb_bd0in[2]
No documentation found
const byte USB_EP_OUT_IN = 0x0E -- Cfg both OUT & IN pipes for this ep
No documentation found
var volatile byte usb_bd3out_cnt at usb_bd3out[1]
No documentation found
var volatile byte usb_bd4out_stat at usb_bd4out[0]
No documentation found
var volatile word usb_sdp_value at usb_sdp_loc + 2
No documentation found
const byte USB_VENDOR_INTF = 0xFF
Vendor specific interface code
var volatile byte usb_bd2in_addrl at usb_bd2in[2]
No documentation found
var volatile byte usb_bd2in_addrh at usb_bd2in[3]
No documentation found
const byte USB_DT_INTERFACE = 0x04
No documentation found
var volatile byte usb_bd3in_addrh at usb_bd3in[3]
No documentation found
var volatile word usb_bd1in_addr at usb_bd1in[2]
No documentation found
const byte USB_BDSTATUS_BSTALL = 2 -- 1 buffer stall enabled, 0 buffer stall disabled
No documentation found
const byte USB_CM_CTRL_READ_AWAITING_STATUS = 5 -- Device is awaiting reception of status after sending data
No documentation found
var volatile byte usb_bd_array[ 255 ] at ( USB_BASE_ADDRESS + 0x0000 )
No documentation found
const byte USB_EPT_ISO = 0x01 -- Isochronous Transfer
No documentation found
var volatile bit EP3STALL at UEP3:0
No documentation found
const byte USB_BDSTATUS_UOWN = 7 -- 0 if uC owns buffer
Bits of BDn.stat when UOWN = 0
var volatile bit EP3HSHK at UEP3:4
No documentation found
var volatile byte usb_bd1in_addrh at usb_bd1in[3]
No documentation found
var volatile byte usb_bd5out_stat at usb_bd5out[0]
No documentation found
const byte USB_V25TER = 0x01 -- Common AT commands ("Hayes(TM)")
Communication Interface Class Control Protocol Codes
var volatile byte usb_bd3in_addrl at usb_bd3in[2]
No documentation found
const byte USB_DT_INTERFACE_ASSOC = 0x0b
No documentation found
const byte USB_REQUEST_GET_DESCRIPTOR = 0x06
No documentation found
var volatile bit EP3INEN at UEP3:1
No documentation found
var byte usb_delivery_buffer[ 8 ] at USB_IN_DELIVERY_BUFFER_LOC
No documentation found
const byte USB_HID_INTF = 0x03
No documentation found
var volatile word usb_bd2out_addr at usb_bd2out[2]
No documentation found
const byte USB_DT_DEVICE_QUALIFIER = 0x06
No documentation found
const byte USB_PID_DATA2 = 0b00000111
No documentation found
var volatile word usb_bd3in_addr at usb_bd3in[2]
No documentation found
var volatile byte usb_bd4in_addrl at usb_bd4in[2]
No documentation found
const byte USB_STATUS_SET_ADDRESS = 1
No documentation found
var volatile bit EP2INEN at UEP2:1
No documentation found
var volatile byte usb_bd2out_stat at usb_bd2out[0]
No documentation found
const byte USB_BDSTATUS_BC8 = 0 -- bit 8 of buffer count
No documentation found
const byte USB_LOW_SPEED = 0x00
No documentation found
var volatile byte usb_sdp[8] at usb_sdp_loc
No documentation found
var volatile bit EP1HSHK at UEP1:4
No documentation found
const byte USB_BDSTATUS_INCDIS = 4 -- 1 Address increment disabled (for SPP), 0 address increment enabled
No documentation found
const bit USB_SELF_POWERED = 1
No documentation found
const byte USB_EP_CTRL = 0x06 -- Cfg Control pipe for this ep
No documentation found
const byte USB_STATE_ADDRESS = 2 -- USB device now has an address
No documentation found
const byte USB_BD_STAT_IDX = 0x00
No documentation found
var volatile byte usb_bd4out[4] at ( USB_BASE_ADDRESS + 0x0020 )
No documentation found
const byte USB_STATUS_IDLE = 0
USB_STATUS
var volatile byte usb_bd0out[4] at ( USB_BASE_ADDRESS + 0x0000 )
No documentation found
var volatile bit EP2STALL at UEP2:0
No documentation found
var volatile byte usb_bd0out_cnt at usb_bd0out[1]
No documentation found
var volatile word usb_bd4out_addr at usb_bd4out[2]
No documentation found
var volatile byte usb_bd2out_cnt at usb_bd2out[1]
No documentation found
var volatile bit EP2OUTEN at UEP2:2
No documentation found
var volatile byte usb_bd5out_addrh at usb_bd5out[3]
No documentation found
const byte USB_BD_ADDRH_IDX = 0x02
No documentation found
var volatile word usb_bd2in_addr at usb_bd2in[2]
No documentation found
var volatile byte usb_bd3in_stat at usb_bd3in[0]
No documentation found
const byte USB_CDC_DEVICE = 0x02
Device Class Code
const byte USB_PID_OUT = 0b00000001
Token
const byte USB_BDSTATUS_DTSEN = 3 -- 1 data toggle sync on, 0 data toggle sync off
No documentation found
const byte USB_PULLUP_DISABLED = 0x00
No documentation found
const byte USB_EPT_CTRL = 0x00 -- Control Transfer
Endpoint Transfer Type
const byte USB_PID_DATA0 = 0b00000011
Data
var volatile byte usb_bd1in_stat at usb_bd1in[0]
No documentation found
const byte USB_REQUEST_SET_DESCRIPTOR = 0x07
No documentation found
var volatile byte usb_bd3out_addrl at usb_bd3out[2]
No documentation found
const byte USB_REQUEST_GET_INTERFACE = 0x0a
No documentation found
var volatile byte usb_bd3out_addrh at usb_bd3out[3]
No documentation found
const byte USB_REQUEST_SET_FEATURE = 0x03
No documentation found
var byte usb_address
No documentation found
var volatile byte usb_bd2out_addrh at usb_bd2out[3]
No documentation found
var volatile byte usb_bd1out_addrl at usb_bd1out[2]
No documentation found
const byte USB_PID_STALL = 0b00001110
No documentation found
var volatile byte usb_bd2in[4] at ( USB_BASE_ADDRESS + 0x0014 )
No documentation found
var volatile byte usb_bd4in_cnt at usb_bd4in[1]
No documentation found
var volatile bit EP1INEN at UEP1:1
No documentation found
var volatile byte usb_bd4in_stat at usb_bd4in[0]
No documentation found
var volatile byte usb_bd0in[4] at ( USB_BASE_ADDRESS + 0x0004 )
No documentation found
var volatile word usb_bd4in_addr at usb_bd4in[2]
No documentation found
const USB_DEVICE_DESCRIPTOR_SIZE = 18
No documentation found
var volatile byte usb_bd5out_addrl at usb_bd5out[2]
No documentation found
const byte USB_PULLUP_ENABLE = 0x10
No documentation found
const byte USB_DT_CONFIGURATION = 0x02
No documentation found
var volatile byte usb_bd0out_stat at usb_bd0out[0]
No documentation found
const byte USB_DT_OTHER_SPEED_CONFIG = 0x07
No documentation found
var volatile word usb_bd0out_addr at usb_bd0out[2]
No documentation found
const byte USB_FULL_SPEED = 0x04
No documentation found
const byte USB_EPT_INT = 0x03 -- Interrupt Transfer
No documentation found
const word usb_sdp_loc = ( USB_BASE_ADDRESS + 0x00F8 )
No documentation found
var volatile byte usb_bd3out[4] at ( USB_BASE_ADDRESS + 0x0018 )
No documentation found
var volatile byte usb_bd4out_addrl at usb_bd4out[2]
No documentation found
var volatile byte usb_bd5out[4] at ( USB_BASE_ADDRESS + 0x0028 )
No documentation found
var volatile byte usb_bd2in_stat at usb_bd2in[0]
No documentation found
var byte usb_delivery_bytes_sent
No documentation found
const byte USB_PID_SETUP = 0b00001101
No documentation found
var volatile byte usb_bd1in_cnt at usb_bd1in[1]
No documentation found
var volatile byte usb_sdp_request_type at usb_sdp_loc
No documentation found
const byte USB_DT_STRING = 0x03
No documentation found
const byte USB_BOOT_INTF_SUBCLASS = 0x01
No documentation found
var volatile byte usb_bd4in_addrh at usb_bd4in[3]
No documentation found
const byte USB_HID_PROTOCOL_MOUSE = 0x02
No documentation found
var volatile word usb_bd5in_addr at usb_bd5in[2]
No documentation found
var volatile bit EP1STALL at UEP1:0
No documentation found
const byte USB_EP_IN = 0x0A -- Cfg IN only pipe for this ep
No documentation found
var volatile byte usb_bd0in_cnt at usb_bd0in[1]
No documentation found
const USB_REQUEST_TYPE1_BIT = 6 -- 00= USB standard request
No documentation found
const byte USB_PING_PONG__FULL_PING_PONG = 0x02 -- 0b10
No documentation found
var volatile word usb_sdp_index at usb_sdp_loc + 4
No documentation found
const USB_DATA_STAGE_DIR_BIT = 7
No documentation found
const byte USB_PID_SOF = 0b00000101
No documentation found
const byte USB_CM_CTRL_READ_DATA_STAGE = 3 -- Device sending data during the data stage
No documentation found
var volatile byte usb_bd3in[4] at ( USB_BASE_ADDRESS + 0x001C )
No documentation found
const byte USB_HSHK_EN = 0x10 -- Enable handshake packet
No documentation found
const byte USB_PING_PONG__NO_PING_PONG = 0x00 -- 0b00
No documentation found
const byte USB_PING_PONG__EP0_OUT_ONLY = 0x01 -- 0b01
No documentation found
const byte USB_CM_IDLE = 0 -- No control transfer taking place
USB COMMAND MODES
const byte USB_HIGHEST_EP = 3
No documentation found
const byte USB_BDSTATUS_DTS = 6 -- 1 data 1 packet, 0 data 0 packet
No documentation found
var byte usb_state = USB_STATE_POWERED
No documentation found
var volatile byte usb_bd2out_addrl at usb_bd2out[2]
No documentation found
var volatile bit EP1OUTEN at UEP1:2
No documentation found
const byte USB_REQUEST_GET_STATUS = 0x00
USB REQUESTS
const byte USB_CM_CTRL_READ_DATA_STAGE_CLASS = 4 -- Device class is sending data during the data stage
No documentation found
const byte USB_DT_ENDPOINT = 0x05
No documentation found
const byte USB_PID_ACK = 0b00000010
Handshake
var volatile byte usb_bd0in_addrl at usb_bd0in[2]
No documentation found
const byte USB_PID_NAK = 0b00001010
No documentation found
const byte USB_REQUEST_GET_CONFIGURATION = 0x08
No documentation found
const byte USB_DT_DEVICE = 0x01
No documentation found
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_generic.jal |
Author | Albert Faber, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | - |
Compiler | >=2.4j |
This file contains the lowl level USB driver routines. It constrols the USB serial interface engine, by managing the input and output transfers, and calling the defined callback function when required
http://www.usb.org ; for USB specifications http://www.lvr.com/usbc.htm ; a lot of information about USB http://www.beyondlogic.org/ ; also a nice with with useful information
No dependency found
usb_enable_module()
Procedure to turn on the USB device
usb_handle_stall()
Procedure can be called when the USB device has to be stalled
usb_setup()
Procedure to intialize the USB device, it will only do the setup, to enable the USB device, use the usb_enable() procedure
usb_handle_isr()
This is the heard of the USB library, all pending IO transfers are handled by this main (interrupt) service routine. For the PIC USB device it does not make much sense to use real interrupts since all real time aspects are handle by the SIE. Therefore this usb_handle_isr() must be polled on a regular base, in order to to keep the input and output transfers flowing
_usb_handle_standard_request()
Internal procedure to handle standard USB requests it will take care of the overall state of the device performing USB buffer management controlling the SIE and call the callback function if required
_usb_ints_on()
Internal procedure to set the correct interrupt flags, note that for PIC USB device it does not make much sense to use real interrupts since all real time aspects are handle by the SIE. However, the library does use the interrupt flags, this procedure will setup to proper interrupt flags
_usb_handle_transaction()
Internal procedure to handle the USB transactions it will take care of the overall state of the device performing USB buffer management controlling the SIE and call the callback function if required
_usb_handle_reset()
Internal procedure to reset the USB device
usb_is_configured() return bit
Function returns true if the usb device has been completely configured, otherwise return value will be false
usb_get_state() return byte
Get the state of the USB device USB_STATE_POWERED -> USB device is powered up, ready to start negotiating USB_STATE_DEFAULT -> USB device is now negotiating USB_STATE_ADDRESS -> USB device now has an address USB_STATE_CONFIGURED -> USB device is completely configured and ready to rock and roll
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_generic.jal |
Author | Albert Faber, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | - |
Compiler | >=2.4j |
USB Communication Device Class (CDC) code This USB library files contains the low level implementation to perform serial communication over a USB interface. The usage of this library requires detailed knowledge of the USB interface and requires that several configuration parameters are defined correctly. In order to make USB serial communication more accessible for the end user, I would highly recommend to use the usb_serial library
http://www.usb.org for USB specifications
No dependency found
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
var volatile word cdc_out_addr is usb_bd3out_addr
var volatile byte cdc_rx_rd = 0
var volatile byte cdc_line_coding[7]
var volatile byte cdc_out_stat is usb_bd3out_stat
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
var volatile byte cdc_in_cnt is usb_bd3in_cnt
var volatile byte cdc_out_addrl is usb_bd3out_addrl
var volatile byte cdc_tx_rd=0
var volatile byte cdc_line_coding_data_bits at cdc_line_coding[6] -- 5,6,7,8 or 16 bits
const byte USB_REQ_SEND_BREAK = 0x23
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
const byte USB_REQ_SET_COMM_FEATURE = 0x02
const byte USB_REQ_SET_LINE_CODING = 0x20
const byte USB_REQ_GET_LINE_CODING = 0x21
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
var volatile byte cdc_in_addrh is usb_bd3in_addrh
var volatile byte cdc_line_coding_parity at cdc_line_coding[5] -- 0=None, 1=Odd, 2=Even, 3=Mark, 4=Space
var volatile byte cdc_in_addrl is usb_bd3in_addrl
var volatile byte cdc_out_addrh is usb_bd3out_addrh
var byte idx
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
var volatile byte cdc_out_cnt is usb_bd3out_cnt
var volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
var volatile byte tmp_cdc[7] at 0x700
var volatile byte cdc_in_stat is usb_bd3in_stat
var volatile word cdc_in_addr is usb_bd3in_addr
var volatile byte cdc_rx_wr = 0
var byte cdc_line_status = 0x00
var volatile byte cdc_tx_wr=0
var volatile byte cdc_line_coding_stop_bits at cdc_line_coding[4] -- 0=1 stop bit, 1=1.5 stop bits, 2=2 stop bits
var bit last_packet_is_full = false
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
usb_handle_class_request_callback()
usb_handle_class_ctrl_read_callback()
usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)
usb_cdc_putc(byte in c)
usb_cdc_handle_tx()
usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)
usb_handle_class_ctrl_write_callback()
usb_sof_callback()
usb_cdc_setup()
usb_cdc_rx_avail() return bit
does_sie_owns_tx_buffer() return bit
usb_cdc_line_status() return byte
usb_cdc_getc() return byte
usb_cdc_tx_empty() return byte
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
No documentation found
var volatile word cdc_out_addr is usb_bd3out_addr
No documentation found
var volatile byte cdc_rx_rd = 0
No documentation found
var volatile byte cdc_line_coding[7]
No documentation found
var volatile byte cdc_out_stat is usb_bd3out_stat
No documentation found
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
No documentation found
var volatile byte cdc_in_cnt is usb_bd3in_cnt
No documentation found
var volatile byte cdc_out_addrl is usb_bd3out_addrl
No documentation found
var volatile byte cdc_tx_rd=0
No documentation found
var volatile byte cdc_line_coding_data_bits at cdc_line_coding[6] -- 5,6,7,8 or 16 bits
No documentation found
const byte USB_REQ_SEND_BREAK = 0x23
No documentation found
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
No documentation found
const byte USB_REQ_SET_COMM_FEATURE = 0x02
No documentation found
const byte USB_REQ_SET_LINE_CODING = 0x20
No documentation found
const byte USB_REQ_GET_LINE_CODING = 0x21
No documentation found
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
No documentation found
var volatile byte cdc_in_addrh is usb_bd3in_addrh
No documentation found
var volatile byte cdc_line_coding_parity at cdc_line_coding[5] -- 0=None, 1=Odd, 2=Even, 3=Mark, 4=Space
No documentation found
var volatile byte cdc_in_addrl is usb_bd3in_addrl
No documentation found
var volatile byte cdc_out_addrh is usb_bd3out_addrh
No documentation found
var byte idx
No documentation found
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
No documentation found
var volatile byte cdc_out_cnt is usb_bd3out_cnt
No documentation found
var volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
No documentation found
var volatile byte tmp_cdc[7] at 0x700
No documentation found
var volatile byte cdc_in_stat is usb_bd3in_stat
No documentation found
var volatile word cdc_in_addr is usb_bd3in_addr
No documentation found
var volatile byte cdc_rx_wr = 0
No documentation found
var byte cdc_line_status = 0x00
No documentation found
var volatile byte cdc_tx_wr=0
No documentation found
var volatile byte cdc_line_coding_stop_bits at cdc_line_coding[4] -- 0=1 stop bit, 1=1.5 stop bits, 2=2 stop bits
No documentation found
var bit last_packet_is_full = false
No documentation found
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
No documentation found
usb_handle_class_request_callback()
No documentation found
usb_handle_class_ctrl_read_callback()
No documentation found
usb_ep_data_out_callback(byte in end_point, word in buffer_addr, byte in byte_count)
No documentation found
usb_cdc_putc(byte in c)
This usb_cdc_putc will transmit the specified character. Under normal conditions the character to be transmitted is placed into the fifo, so the call will be non blocking. This implies that buffer overruns can occur when the transmit FIFO is full. Therefore it is adviced to check the transmit FIFO state before calling this procedure to avoid buffer overruns. These buffer overrun issues have been addressed in the usb_serial library, therefore it is highly recommended to use this library instead of calling this low level procedure
usb_cdc_handle_tx()
This procedure will handle the transmission of the (bulk) data. The procedure check if there are pending characters in the tranmit FIFO. These character(s) are send in chunk(s), the chunk size is dependent on the conifguration of the bulk interface endpoint
usb_ep_data_in_callback(byte in end_point, word in buffer_addr, byte in byte_count)
This function is called when data can be transmitted via the bulk interface
usb_handle_class_ctrl_write_callback()
No documentation found
usb_sof_callback()
No documentation found
usb_cdc_setup()
This procedure will intialize the line status of the communicatin device class
usb_cdc_rx_avail() return bit
This function returns there has been a character received, function will return true if there is at least one pending receive character, false otherwise
does_sie_owns_tx_buffer() return bit
This function returns the status of the SIE tx buffer. Either the SIE can own the transmit buffer (tranmit is pending) or it can be owned by the CPU. This function return true if the SIE owns the buffer, otherwise false is returned
usb_cdc_line_status() return byte
This function returns the line status. If on the host side the COM port has not been opened, the return status will be 0x00, otherwise it will be != 0
usb_cdc_getc() return byte
This usb_cdc_getc function wait (blocking) until a character has been received. The byte value of the received character is returned by this function
usb_cdc_tx_empty() return byte
This function returns the empty status of the transmit FIFO, it will return true if transmit FIFO is empty, false otherwise
Author | Albert Faber, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | - |
Compiler | >=2.4j |
Routines for controlling the USB serial interface engine sending which will ensure the highest possible accuracy.
http://www.usb.org for USB specifications
No dependency found
usb_send_one_byte(byte in data)
usb_stall_ep0()
usb_prime_epx_out( byte in end_point, byte in size )
usb_send_empty_data_pkt()
usb_send_status_ack()
usb_send_data_chunk()
usb_send_data(byte in endpoint, byte in data[], byte in byte_cnt, bit in is_new_sequence )
usb_configure_endpoints()
usb_prime_ep0_out()
usb_send_one_byte(byte in data)
This procedure will send one byte, with the contend specified by the data input parameter, normally not called by the end user
usb_stall_ep0()
No documentation found
usb_prime_epx_out( byte in end_point, byte in size )
No documentation found
usb_send_empty_data_pkt()
This procedure sends an empty USB packet, normally not called by the end user
usb_send_status_ack()
This procedure sends an USB acknowledge packet, normally not called by the end user
usb_send_data_chunk()
This procedure sends the content of the USB delivery buffer in the USB SIE
usb_send_data(byte in endpoint, byte in data[], byte in byte_cnt, bit in is_new_sequence )
This procedure will send the content of an array to the USB end point. The endpoint input parameter contains the the enpoint number, data[] is the content to be send, byte_cnt the number of bytes to be send, and is_new_sequence determines if the data tranmission is starting with USB packet o (if set to true), otherwise the USB packet is toggled before transmission.
usb_configure_endpoints()
This procedure will setup and initalize the USB endpoints, normally not called by the end user
usb_prime_ep0_out()
No documentation found
_usb_copy_array_to_ram( WORD in dst, byte in data[], byte in num_bytes )
Internal memory copy procedure This function copies the content from a source array towards the specified destination memory location. The function copies num_bytes bytes
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_hid_generic.jal |
Author | Albert Faber, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
The library will ease the use of for serial communication over the USB interface. By default nothing has to be defined by the user, below an example how to use the library include usb_serial .. usb_serial_init() .. ;-- optionally wait till USB becomes available while ( usb_cdc_line_status() == 0x00 ) loop end loop .. ;-- main loop var byte ch forever loop ; -- call the flush routine on a regular base in the main loop ; -- in order to keep the USB communicaiton alive usb_serial_flush() if ( usb_serial_read( ch ) ) usb_serial_data = ch -- echo end if ..... end loop In addition this library can be used in combination with other JAL libraries, like print.jal and format.jal, for example to send a string, one can use the following code fragment: const byte str[] = "Hello World" print_string( usb_serial_data, str ) customization The usb_serial library offers the following custimization prameters, the user has the ability to set these const parameter(s) before the inclusion of the usb_serial file const byte USB_CDC_RX_BUFFER_SIZE = 0x?? -- set receive FIFO size const byte USB_CDC_TX_BUFFER_SIZE = 0x?? -- set transmit FIFO size const word USB_SERIAL_PRODUCT_ID = 0x???? -- set USB device product ID const word USB_SERIAL_VENDOR_ID = 0x???? -- set USB device vendor ID const byte USB_STRING0[] = { .. } -- set USB language string const byte USB_STRING1[] = { .. } -- set USB mfg string const byte USB_STRING2[] = { .. } -- set USB product string
-
const byte USB_DSC_FN_ACM = 0x02 -- ACM - Abstract Control Management
const word USB_EP1_IN_ADDR = (USB_EP1_OUT_ADDR + USB_EP1_OUT_SIZE )
const byte USB_DSC_FN_USB_TERMINAL = 0x09
const bit USB_EP1 = 1
const byte USB_DSC_FN_RPT_CAPABILITIES = 0x05
const byte USB_EP1_OUT_SIZE = 8
var volatile byte usb_cdc_eptx_buffer[USB_EP3_IN_SIZE] at USB_EP3_IN_ADDR
const byte USB_DSC_FN_TELEPHONE_RINGER = 0x04
const byte USB_DSC_FN_UNION = 0x06
const byte USB_EP1_IN_SIZE = 8
const byte USB_EP2_IN_SIZE = 8
const byte USB_DSC_FN_TEL_OP_MODES = 0x08
const word USB_EP1_OUT_ADDR = (USB_BASE_ADDRESS + 0x0030 )
var volatile byte usb_ep1in_buf[ USB_EP1_IN_SIZE ] at USB_EP1_IN_ADDR
const byte USB_EP3_OUT_SIZE = 8
const byte USB_STRING1[0x36] =
const byte USB_DSC_FN_CALL_MGT = 0x01
const word USB_SERIAL_PRODUCT_ID = 0x000A
const byte USB_DSC_FN_COUNTRY_SELECTION = 0x07
const byte USB_STRING0[] =
const word USB_EP0_OUT_ADDR = (USB_BASE_ADDRESS + 0x0020 )
const byte USB_EP3_IN_SIZE = 8
const bit USB_EP3 = 1
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
const word USB_SERIAL_VENDOR_ID = 0x04D8
const byte USB_CDC_NO_PROTOCOL = 0x00 -- No class specific protocol required
const word USB_EP2_OUT_ADDR = (USB_BASE_ADDRESS + 0x0040 )
var volatile byte usb_ep3out_buf[ USB_EP3_OUT_SIZE ] at USB_EP3_OUT_ADDR
const byte USB_EP0_IN_SIZE = 8
const word USB_CDC_BULK_OUT_EP_ADDR = USB_EP3_OUT_ADDR
const byte USB_CDC_DATA_ENDPOINT = 3
var volatile byte usb_ep1out_buf[ USB_EP1_OUT_SIZE ] at USB_EP1_OUT_ADDR
const byte USB_DSC_FN_DLM = 0x03 -- DLM - Direct Line Managment
const bit USB_EP2 = 1
const word USB_CDC_LINE_CODING_LOC = (USB_BASE_ADDRESS + 0x00E8 )
const byte USB_STRING2[30] =
const byte USB_CONFIGURATION_DESCRIPTOR[ USB_CONFIGURATION_DESCRIPTOR_SIZE ]=
const byte USB_CDC_BULK_IN_EP_SIZE = USB_EP3_IN_SIZE
const byte USB_CDC_RX_BUFFER_SIZE = 0x10
const byte USB_EP0_OUT_SIZE = 8
const word USB_EP2_IN_ADDR = (USB_EP2_OUT_ADDR + USB_EP2_OUT_SIZE )
var volatile byte usb_ep3in_buf[ USB_EP3_IN_SIZE ] at USB_EP3_IN_ADDR
const word USB_EP3_OUT_ADDR = (USB_BASE_ADDRESS + 0x0050 )
const byte USB_CDC_DATA_INTF = 0x0A
const byte USB_CS_INTERFACE = 0x24
const byte USB_EP2_OUT_SIZE = 8
const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x05 + 0x04 + 0x05 + 0x05 + 0x07 + 0x09 + 0x07 + 0x07
const byte USB_DSC_FN_HEADER = 0x00
var volatile byte usb_ep2in_buf[ USB_EP2_IN_SIZE ] at USB_EP2_IN_ADDR
var volatile byte usb_ep0in_buf[ USB_EP0_IN_SIZE ] at USB_EP0_IN_ADDR
const word USB_EP0_IN_ADDR = (USB_EP0_OUT_ADDR + USB_EP0_OUT_SIZE )
const byte USB_CDC_INT_EP_SIZE = 8
const byte USB_CDC_COMM_INTF_ID = 0x00
var volatile byte usb_ep0out_buf[ USB_EP0_OUT_SIZE ] at USB_EP0_OUT_ADDR
const word USB_EP3_IN_ADDR = (USB_EP3_OUT_ADDR + USB_EP3_OUT_SIZE )
const word USB_CDC_BULK_IN_EP_ADDR = USB_EP3_IN_ADDR
const byte USB_CDC_DATA_INTF_ID = 0x01
var volatile byte usb_ep2out_buf[ USB_EP2_OUT_SIZE ] at USB_EP2_OUT_ADDR
const byte USB_CS_ENDPOINT = 0x25
const byte USB_DCS_INTERFACE = 0x04
const byte USB_CDC_TX_BUFFER_SIZE = 0x20
var volatile byte usb_cdc_eprx_buffer[USB_EP3_OUT_SIZE] at USB_EP3_OUT_ADDR
const bit USB_EP0 = 1
const byte USB_CDC_BULK_OUT_EP_SIZE = USB_EP3_OUT_SIZE
usb_serial_data'put(byte in data)
usb_serial_init()
usb_serial_flush()
usb_serial_write(byte in data)
const byte USB_DSC_FN_ACM = 0x02 -- ACM - Abstract Control Management
No documentation found
const word USB_EP1_IN_ADDR = (USB_EP1_OUT_ADDR + USB_EP1_OUT_SIZE )
No documentation found
const byte USB_DSC_FN_USB_TERMINAL = 0x09
No documentation found
const bit USB_EP1 = 1
No documentation found
const byte USB_DSC_FN_RPT_CAPABILITIES = 0x05
No documentation found
const byte USB_EP1_OUT_SIZE = 8
No documentation found
var volatile byte usb_cdc_eptx_buffer[USB_EP3_IN_SIZE] at USB_EP3_IN_ADDR
No documentation found
const byte USB_DSC_FN_TELEPHONE_RINGER = 0x04
No documentation found
const byte USB_DSC_FN_UNION = 0x06
No documentation found
const byte USB_EP1_IN_SIZE = 8
No documentation found
const byte USB_EP2_IN_SIZE = 8
No documentation found
const byte USB_DSC_FN_TEL_OP_MODES = 0x08
No documentation found
const word USB_EP1_OUT_ADDR = (USB_BASE_ADDRESS + 0x0030 )
No documentation found
var volatile byte usb_ep1in_buf[ USB_EP1_IN_SIZE ] at USB_EP1_IN_ADDR
No documentation found
const byte USB_EP3_OUT_SIZE = 8
No documentation found
const byte USB_STRING1[0x36] =
USB_STRING1 shall contain the USB device descriptor string The user has the ability to define the string content of USB_STRING1 before inclusion of the usb_serial library to override the default content ("Microchip Technology Inc."). note that the USB shall contain 16 bit unicode characters, little endian encoded, and that the first field of USB_STRING1 shall contain the size of the entire USB_STRING1 array, the second byte shall be set to USB_DT_STRING (=0x03).
const byte USB_DSC_FN_CALL_MGT = 0x01
No documentation found
const word USB_SERIAL_PRODUCT_ID = 0x000A
USB_SERIAL_PRODUCT_ID is set to Microchip CDC if const is not defined by the user of the usb_serial library can set the USB_SERIAL_PRODUCT_ID by defining the const before inclusion of the usb_serial library
const byte USB_DSC_FN_COUNTRY_SELECTION = 0x07
No documentation found
const byte USB_STRING0[] =
USB_STRING0 shall contain the USB strings language ID The user has the ability to define the string content of USB_STRING0 before inclusion of the usb_serial library to override the default content ( 0x0904 ). note that the USB shall contain 16 bit unicode characters, little endian encoded, and that the first field of USB_STRING0 shall contain the size of the entire USB_STRING0 array, the second byte shall be set to USB_DT_STRING (=0x03).
const word USB_EP0_OUT_ADDR = (USB_BASE_ADDRESS + 0x0020 )
No documentation found
const byte USB_EP3_IN_SIZE = 8
No documentation found
const bit USB_EP3 = 1
No documentation found
const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] = {
Sets the default USB_DEVICE_DESCRIPTOR record. It is not expected that the user of the usb_serial library needs to create its own record. However, if needed in exeptional cases, the user has the ability to define the const byte USB_DEVICE_DESCRIPTOR[USB_DEVICE_DESCRIPTOR_SIZE] before inclusion of the usb_serial library
const word USB_SERIAL_VENDOR_ID = 0x04D8
USB_SERIAL_VENDOR_ID is set to Microchip if const is not defined by the user of the usb_serial library. One can set the USB_SERIAL_VENDOR_ID by defining the const before inclusion of the usb_serial library
const byte USB_CDC_NO_PROTOCOL = 0x00 -- No class specific protocol required
No documentation found
const word USB_EP2_OUT_ADDR = (USB_BASE_ADDRESS + 0x0040 )
No documentation found
var volatile byte usb_ep3out_buf[ USB_EP3_OUT_SIZE ] at USB_EP3_OUT_ADDR
No documentation found
const byte USB_EP0_IN_SIZE = 8
No documentation found
const word USB_CDC_BULK_OUT_EP_ADDR = USB_EP3_OUT_ADDR
No documentation found
const byte USB_CDC_DATA_ENDPOINT = 3
No documentation found
var volatile byte usb_ep1out_buf[ USB_EP1_OUT_SIZE ] at USB_EP1_OUT_ADDR
No documentation found
const byte USB_DSC_FN_DLM = 0x03 -- DLM - Direct Line Managment
No documentation found
const bit USB_EP2 = 1
No documentation found
const word USB_CDC_LINE_CODING_LOC = (USB_BASE_ADDRESS + 0x00E8 )
No documentation found
const byte USB_STRING2[30] =
USB_STRING2 shall contain the USB product descriptor string The user has the ability to define the string content of USB_STRING1 before inclusion of the usb_serial library to override the default content ("JAL Serial."). note that the USB shall contain 16 bit unicode characters, little endian encoded, and that the first field of USB_STRING1 shall contain the size of the entire USB_STRING2 array, the second byte shall be set to USB_DT_STRING (=0x03).
const byte USB_CONFIGURATION_DESCRIPTOR[ USB_CONFIGURATION_DESCRIPTOR_SIZE ]=
Sets the default USB_CONFIGURATION_DESCRIPTOR record. It is not expected that the user of the usb_serial library needs to create its own record. However, if needed in exeptional cases, the user has the ability to define the const byte USB_CONFIGURATION_DESCRIPTOR[] before inclusion of the usb_serial library to customize the USB conifguration
const byte USB_CDC_BULK_IN_EP_SIZE = USB_EP3_IN_SIZE
No documentation found
const byte USB_CDC_RX_BUFFER_SIZE = 0x10
USB_CDC_RX_BUFFER_SIZE contains the size of the receive FIFO buffer a large(r) buffer can speed up the transmission speed at the cost of free memory space. The user of the usb_serial library has the ability to control size of the FIFO buffer, by defining the const byte USB_CDC_RX_BUFFER_SIZE = 0x?? before the inclusion of the usb_serial file
const byte USB_EP0_OUT_SIZE = 8
No documentation found
const word USB_EP2_IN_ADDR = (USB_EP2_OUT_ADDR + USB_EP2_OUT_SIZE )
No documentation found
var volatile byte usb_ep3in_buf[ USB_EP3_IN_SIZE ] at USB_EP3_IN_ADDR
No documentation found
const word USB_EP3_OUT_ADDR = (USB_BASE_ADDRESS + 0x0050 )
No documentation found
const byte USB_CDC_DATA_INTF = 0x0A
No documentation found
const byte USB_CS_INTERFACE = 0x24
No documentation found
const byte USB_EP2_OUT_SIZE = 8
No documentation found
const USB_CONFIGURATION_DESCRIPTOR_SIZE = 0x09 + 0x09 + 0x05 + 0x04 + 0x05 + 0x05 + 0x07 + 0x09 + 0x07 + 0x07
No documentation found
const byte USB_DSC_FN_HEADER = 0x00
No documentation found
var volatile byte usb_ep2in_buf[ USB_EP2_IN_SIZE ] at USB_EP2_IN_ADDR
No documentation found
var volatile byte usb_ep0in_buf[ USB_EP0_IN_SIZE ] at USB_EP0_IN_ADDR
No documentation found
const word USB_EP0_IN_ADDR = (USB_EP0_OUT_ADDR + USB_EP0_OUT_SIZE )
No documentation found
const byte USB_CDC_INT_EP_SIZE = 8
set the size of the interrupt interface
const byte USB_CDC_COMM_INTF_ID = 0x00
set the communication interface ID
var volatile byte usb_ep0out_buf[ USB_EP0_OUT_SIZE ] at USB_EP0_OUT_ADDR
No documentation found
const word USB_EP3_IN_ADDR = (USB_EP3_OUT_ADDR + USB_EP3_OUT_SIZE )
No documentation found
const word USB_CDC_BULK_IN_EP_ADDR = USB_EP3_IN_ADDR
No documentation found
const byte USB_CDC_DATA_INTF_ID = 0x01
set the interrupt interface ID
var volatile byte usb_ep2out_buf[ USB_EP2_OUT_SIZE ] at USB_EP2_OUT_ADDR
No documentation found
const byte USB_CS_ENDPOINT = 0x25
No documentation found
const byte USB_DCS_INTERFACE = 0x04
No documentation found
const byte USB_CDC_TX_BUFFER_SIZE = 0x20
USB_CDC_TX_BUFFER_SIZE contains the size of the transmit FIFO buffer a large(r) buffer can speed up the transmission speed at the cost of free memory space. The user of the usb_serial library has the ability to control size of the FIFO buffer, by defining the const byte USB_CDC_TX_BUFFER_SIZE = 0x?? before the inclusion of the usb_serial file
var volatile byte usb_cdc_eprx_buffer[USB_EP3_OUT_SIZE] at USB_EP3_OUT_ADDR
No documentation found
const bit USB_EP0 = 1
No documentation found
const byte USB_CDC_BULK_OUT_EP_SIZE = USB_EP3_OUT_SIZE
No documentation found
usb_serial_data'put(byte in data)
usb_serial_data'put - write char to the USB port, blocking Asynchronuous serial send routine, using the USB Cummunication class Sends byte X (8 bit) to the USB host (via virtual COM port) Note that characters are dropped when the communcation channel on the USB host side is not opened (yet), this is a design choice in order to avoid lockup(s)
usb_serial_init()
usb_serial_init will setup the USB communication, however, this can be a time consuming process, therefore this call is non blocking. In order to check if the USB device has established contact with the HOST USB device, one can call the usb_is_configured() function, see usb_is_configured() documentation for additional details.
usb_serial_flush()
usb_serial_flush shall be called on a regular base (millisecond range) in order to keep the USB transmision alive. Therfore it is adviced to call the usb_serial_flush procedure in the main loop of your application
usb_serial_write(byte in data)
usb_serial_write - write char to the USB port, blocking Asynchronuous serial send routine, using the USB Cummunication class Sends byte X (8 bit) to the USB host (via virtual COM port) Checks (and waits if necessary) if FIFO buffer is full Note that characters are dropped when the communcation channel on the USB host side is not opened (yet), this is a design choice in order to avoid lockup(s)
usb_serial_data'get() return byte
usb_serial_data'get() - read a char (blocking!) usb_serial_data'get() waits till a character has been received and returns it
usb_serial_read(byte out data) return bit
usb_serial_read - read char if available (non-blocking) usb_serial_read returns true if a character has been received, otherwise returns false. If function returns true, the data variable is valid, and contains the character that has been received. In other cases the data variable is not defined Note that characters are dropped when the communcation channel on the USB host side is not opened (yet), this is a design choice in order to avoid lockup(s)
_usb_serial_read(byte out data) return bit
_usb_serial_read - internal use only! _usb_serial_read returns true if a character has been received, otherwise returns false. If function returns true, the data variable is valid, and contains the character that has been received. In other cases the data variable is not defined Note that characters are dropped when the communcation channel on the USB host side is not opened (yet), this is a design choice in order to avoid lockup(s)
18f2450 | 18f2450_usb_serial.jal |
18f4550 | 18f4550_usb_serial.jal |