Author | Stef Mientki, Copyright (c) 2002..2008, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4k |
library to handle ADC peripheral. - support both low and high resolution mode - support a large number of PICs, with - ADC pin configuration - channel selection - clock selection - support Vref How to use it ? See http://jallib.blogspot.com for details...
this is a heavy refactoring/rewriting of original library from Stef Mientki. The main changes are about ADC configuration, which are essentially handled in adc_channels.jal, adc_pindef.jal and adc_clock.jal The original library can be found: - Stef's: http://mientki.ruhosting.nl/pic-tools/jal/libs2/adc_hardware.jal - jallib issue tracker: http://code.google.com/p/jallib/issues/detail?id=7
_adc_init_acquisition_delay()
_adc_read_low_res(byte in adc_chan, byte out adc_byte)
_adc_init_justify()
var volatile byte _adcon0_shadow = 0
No documentation found
var byte adc_conversion_delay
No documentation found
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_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_init_acquisition_delay()
No documentation found
_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_justify()
No documentation found
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
12f683 | 12f683_pwm_adc.jal |
16f767 | 16f767_pwm_adc.jal |
16f77 | 16f77_adc_lowres.jal |
16f876a | 16f876a_adc.jal |
16f877 | 16f877_adc.jal |
16f88 | 16f88_adc_lowres.jal |
16f88 | 16f88_adc_highres.jal |
16f886 | 16f886_pwm_adc_res.jal |
16f886 | 16f886_pwm_adc_freq.jal |
Author | Sebastien Lelong, Copyright (C) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
this library acts as a wrapper. When included, it'll define ways to configure the number ADC channels. There are 3 different cases: 1. the number of channels is specified setting/clearing PCFG bits => a combination of PCFG bits selects a given number of ADC channels. It is not possible to independently select which pins as ADC pins. If available, Vref+ and Vref- are part of these combinations. PCFG bits are in ADCON1, as ADCON1_PCFG 2. the number of channels is specified clearing PCFG bits (case only found in 18F, I think) => pins can be configured independently (you can decide which pin will act as an analog pin, and define your own combination Vref+/Vref- are configured using VCFG bits. PCFG bits are in ADCON0 and ADCON1, and are numbered (eg. ADCON_PCFG5) 3. the number of channels is set using ANS bits (18F and non-18F) => same as case 2., channels can be configured independently Vref+/Vref- are configured using VCFG bits.
this file is generated, don't modify it directly...
No dependency found
adc_adref()
Configure Voltage reference using ADREF bits Found in PICs: 16f722, 16f723, 16f724, 16f726, 16f727, 16lf722, 16lf723, 16lf724, 16lf726, 16lf727, Same family, DS 41341B
adc_vcfg()
Configure Voltage reference using VCFG bits
Author | Sebastien Lelong, Copyright (c) 2009, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4k |
this library provides a procedure to configure ADC clock according to ADC constraints about Tad values and PIC's clock speed
No dependency found
var byte tad_value
No documentation found
_adc_init_clock()
No documentation found
_adc_eval_tad(word in factor) return bit
No documentation found
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
18f14k50 | 18f14k50_usb_hid_generic.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 |
16f886 | 16f886_rtc_lcd_4mhz.jal |
16f886 | 16f886_rtc_lcd_20mhz.jal |
16f886 | 16f886_rtc_lcd_125khz.jal |
Author | Eur van Andel, eur@fiwihex.nl Copyright (c) 2008 |
Adapted-by | Albert Faber |
Compiler | =2.4m |
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_1s(word in n)
delay_3us()
delay_10us(byte in n)
delay_8us()
delay_1ms(word in n)
delay_2us()
delay_4us()
delay_1us()
delay_100ms(word in n)
delay_9us()
delay_6us()
delay_5us()
const instruction_time = 400_000_000 / target_clock
calculate instruction execution time in 10ns units
delay_7us()
fixed delay of 7 usec (no arguments)
delay_1s(word in n)
Delays for n * 1 sec
delay_3us()
fixed delay of 3 usec (no arguments)
delay_10us(byte in n)
Delays for n * 10 usec
delay_8us()
fixed delay of 8 usec (no arguments)
delay_1ms(word in n)
Delays for n * 1 msec
delay_2us()
fixed delay of 2 usec (no arguments)
delay_4us()
fixed delay of 4 usec (no arguments)
delay_1us()
fixed delay of 1 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)
delay_5us()
fixed delay of 5 usec (no arguments)
Author | Matthew Schinkel, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4m |
read and write to 24lc256 i2c eeprom
http://groups.google.com/group/jallib
No dependency found
ee_24lc256_read(byte in ic_address, word in mem_address, byte out data)
ee_24lc256_write(byte in ic_address, word in mem_address, byte in data)
ee_24lc256_read(byte in ic_address, word in mem_address, byte out data)
No documentation found
ee_24lc256_write(byte in ic_address, word in mem_address, byte in data)
No documentation found
18f452 | 18f452_24lc256.jal |
Author | Matthew Schinkel, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
this library reads files & folders from a fat32 formatted media such as sd cards & hard disks. BETA VERSION!
http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx http://www.pjrc.com/tech/8051/ide/fat32.html http://en.wikipedia.org/wiki/File_Allocation_Table
This lib does not create filename's on fat32 partitions, although it may in the future. Please see this article http://www.desktoplinux.com/news/NS4980952387.html?kc=rss before you think about implementing writing of filenames into your project.
No dependency found
var dword fat32_root_dir_first_cluster -- the location of the root dir's first cluster, should be 2
var bit fat32_is_volume_id at fat32_attrib : 3
const byte FAT32_DIRECTORY = 0
var dword fat32_file_cluster -- file's start cluster number after file_read_info()
var word fat32_dir_file_count -- number of files in current directory
var byte fat32_sectors_per_cluster -- the number of sectors per cluster, usually 8
var byte file_ext[3] -- holds file extension after file_read_info()
var bit fat32_is_read_only at fat32_attrib : 0
var bit fat32_filter_is_volume_id at fat32_attrib_filter : 3
var dword fat32_fat_begin -- the location of the file alocation table for current partition
const byte FAT32_ENTRY_IS_PART_OF_LONG_NAME = 0x0F -- entry has a few characters of a long filename
var bit fat32_is_directory at fat32_attrib : 4
var dword fat32_file_size -- holds file size after file_read_info()
var bit fat32_filter_is_archive at fat32_attrib_filter : 5
var byte fat32_attrib
var dword fat32_root_dir -- sector location of the root dir
var byte fat32_attrib_filter = 0 -- default is do not filter any file attributes
var bit fat32_is_hidden at fat32_attrib : 1
var bit fat32_filter_is_system at fat32_attrib_filter : 2
const byte FAT32_ENTRY_NOT_IN_USE = 0xE5 -- usually from a deleted file
var bit fat32_filter_is_directory at fat32_attrib_filter : 4
var bit fat32_is_system at fat32_attrib : 2
var dword fat32_file_location -- holds file location after file_read_info()
var dword fat32_cluster_begin -- the location of the beginning of clusters (where files & folders data is)
var byte fat32_filename_count = 0
var dword fat32_current_dir_location -- sector location of last dir read
const BYTE FAT32_FILE = 1
var bit fat32_filter_is_hidden at fat32_attrib_filter : 1
var bit fat32_is_archive at fat32_attrib : 5
var bit fat32_filter_is_read_only at fat32_attrib_filter : 0
fat32_write_entry(word in address, byte*FAT32_ENTRIES_MAX in entry_data)
fat32_read_boot_sector(byte in partition_select)
fat32_list_dir()
fat32_read_file_info(byte*FAT32_ENTRIES_MAX in file_number)
fat32_read_filename()
fat32_read_entry(word in address, byte*FAT32_ENTRIES_MAX out entry_data)
fat32_create_dword(byte in val4, byte in val3, byte in val2, byte in val1, dword out result1)
fat32_read_file(byte out in_b, byte out in_a)
fat32_init(byte in primary_partition_number)
fat32_file_open(byte in file_number) return bit
fat_32_read_filename_char() return byte
fat32_cd(byte in file_number) return bit
var dword fat32_root_dir_first_cluster -- the location of the root dir's first cluster, should be 2
No documentation found
var bit fat32_is_volume_id at fat32_attrib : 3
No documentation found
const byte FAT32_DIRECTORY = 0
read fragment locations from fat, store in fat32_dir_fragments_start & fat32_dir_fragment_cluster_count arrays
var dword fat32_file_cluster -- file's start cluster number after file_read_info()
No documentation found
var word fat32_dir_file_count -- number of files in current directory
No documentation found
var byte fat32_sectors_per_cluster -- the number of sectors per cluster, usually 8
No documentation found
var byte file_ext[3] -- holds file extension after file_read_info()
No documentation found
var bit fat32_is_read_only at fat32_attrib : 0
No documentation found
var bit fat32_filter_is_volume_id at fat32_attrib_filter : 3
No documentation found
var dword fat32_fat_begin -- the location of the file alocation table for current partition
No documentation found
const byte FAT32_ENTRY_IS_PART_OF_LONG_NAME = 0x0F -- entry has a few characters of a long filename
No documentation found
var bit fat32_is_directory at fat32_attrib : 4
No documentation found
var dword fat32_file_size -- holds file size after file_read_info()
vars you can read info from
var bit fat32_filter_is_archive at fat32_attrib_filter : 5
No documentation found
var byte fat32_attrib
Create file fat32_attribute variables
var dword fat32_root_dir -- sector location of the root dir
No documentation found
var byte fat32_attrib_filter = 0 -- default is do not filter any file attributes
filter file attributes
var bit fat32_is_hidden at fat32_attrib : 1
No documentation found
var bit fat32_filter_is_system at fat32_attrib_filter : 2
No documentation found
const byte FAT32_ENTRY_NOT_IN_USE = 0xE5 -- usually from a deleted file
READ DIR INFO, STORE INTO ENTRY_LOCATION ARRAY refers to fat32 directory entry characters
var bit fat32_filter_is_directory at fat32_attrib_filter : 4
No documentation found
var bit fat32_is_system at fat32_attrib : 2
No documentation found
var dword fat32_file_location -- holds file location after file_read_info()
No documentation found
var dword fat32_cluster_begin -- the location of the beginning of clusters (where files & folders data is)
No documentation found
var byte fat32_filename_count = 0
No documentation found
var dword fat32_current_dir_location -- sector location of last dir read
No documentation found
const BYTE FAT32_FILE = 1
No documentation found
var bit fat32_filter_is_hidden at fat32_attrib_filter : 1
No documentation found
var bit fat32_is_archive at fat32_attrib : 5
No documentation found
var bit fat32_filter_is_read_only at fat32_attrib_filter : 0
No documentation found
fat32_write_entry(word in address, byte*FAT32_ENTRIES_MAX in entry_data)
these procedures may get removed.
fat32_read_boot_sector(byte in partition_select)
Reads a fat32 boot sector to get the location of the root directory and FAT Location on the media for the partition selected. Only primary partitions are supported. Secondary partitions are not.
fat32_list_dir()
requires serial connection to your pc, you may modify this for your own application requires: include format.jal, serial_hw.jal
fat32_read_file_info(byte*FAT32_ENTRIES_MAX in file_number)
reads file info such as filename, filesize, filelocation, etc. into memory.
fat32_read_filename()
send the current filename via serial port, you may modify this for your own application. requires serial_hw.jal
fat32_read_entry(word in address, byte*FAT32_ENTRIES_MAX out entry_data)
No documentation found
fat32_create_dword(byte in val4, byte in val3, byte in val2, byte in val1, dword out result1)
creates a dword from 4 bytes old procedure, needs to be fixed or removed
fat32_read_file(byte out in_b, byte out in_a)
read data from the currently opened file.
fat32_init(byte in primary_partition_number)
initalize fat32
_fat32_send_dword(DWORD in dval1)
Send dword via serial port (for troubleshooting only)
fat32_file_open(byte in file_number) return bit
No documentation found
fat_32_read_filename_char() return byte
No documentation found
fat32_cd(byte in file_number) return bit
change directory, returns 1 = success, 0 = not a directory
18f452 | 18f452_fat32_sd_card.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
Author | Stef Mientki, Copyright (c) 2002 .. 2006, all rights reserved. |
Adapted-by | Joep Suijs, Albert Faber, Eur van Andel |
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 bit _format_signed = false
No documentation found
var byte _format_leader
global vars
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_print.jal |
16f648a | 16f648a_serial_format.jal |
16f723 | 16f723_serial_print.jal |
16f723 | 16f723_serial_format.jal |
16f876a | 16f876a_sht.jal |
16f876a | 16f876a_rtc_lcd.jal |
16f876a | 16f876a_tc77.jal |
16f877a | 16f877a_print_serial_numbers.jal |
16f877a | 16f877a_lcd_format.jal |
16f877a | 16f877a_rtc_lcd.jal |
16f877a | 16f877a_serial_format.jal |
16f877a | 16f877a_serial_print.jal |
16f88 | 16f88_print_serial_numbers.jal |
16f88 | 16f88_serial_print.jal |
16f886 | 16f886_rtc_lcd_4mhz.jal |
16f886 | 16f886_pwm_adc_freq.jal |
16f886 | 16f886_rtc_lcd_20mhz.jal |
16f886 | 16f886_rtc_lcd_125khz.jal |
16f886 | 16f886_pwm_adc_res.jal |
18f14k50 | 18f14k50_serial_format.jal |
18f14k50 | 18f14k50_serial_print.jal |
18f2450 | 18f2450_serial_format.jal |
18f2450 | 18f2450_serial_print.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
18f452 | 18f452_fat32_sd_card.jal |
18f4550 | 18f4550_serial_format.jal |
18f4550 | 18f4550_serial_print.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.5C SMD (LCC) SHT11 3.0% 0.4C SMD (LCC) SHT15 2.0% 0.3C SMD (LCC) SHT71 3.0% 0.4C 4-pin single-in-line SHT75 1.8% 0.3C 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 this library doesn't perform any CRC check
http://www.sensirion.com/en/01_humidity_sensors/00_humidity_sensors.htm
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()
read_centicelsius_temp_sht(sword out centicelsius)
sht_put_data(byte in x)
read_celsius_temp_sht(sbyte out celsius)
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 _____ ________ DATA: |_______| ___ ___ SCK : ___| |___| |______
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
read_centicelsius_temp_sht(sword out centicelsius)
read Celcius temperature from SHT with 0.01 C resolution, result is sword type, so -327.68 .. +327.68 C SHT takes 320 ms for measurement @ 14 bits we will wait 400 ms SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every four seconds!
sht_put_data(byte in x)
send one byte to the SHT
read_celsius_temp_sht(sbyte out celsius)
read Celcius temperature from SHT with 1 C resolution, result is sbyte type, so -126...+127C SHT takes 320 ms for measurement @ 14 bits we will wait 400 ms SHT may only be switched on for 10% of the time because of self-heating so this measurement can only happen every four seconds!
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 320 ms for measurement @ 14 bits we will wait 400 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, Albert Faber |
Compiler | >=2.4g |
Hardware implementation of I2C (single) master. Define i2c pins like: alias i2c_scl is pin_c3 ; optional, but good habit ;) alias i2c_scl_direction is pin_c3_direction alias i2c_sda is pin_c4 ; optional, but good habit ;) alias i2c_sda_direction is pin_c4_direction const word _i2c_bus_speed = 1 ; * 100kHz const bit _i2c_level = true ; i2c levels (not SMB)
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_l0.jal |
16f877a | 16f877a_i2c_hw_l1.jal |
18f14k50 | 18f14k50_i2c_hw_l1.jal |
18f14k50 | 18f14k50_i2c_hw_l0.jal |
18f4550 | 18f4550_i2c_hw_l1.jal |
18f4550 | 18f4550_i2c_hw_l0.jal |
Author | Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | Joep Suijs, Albert Faber |
Compiler | >=2.4i |
Common and useful functions and procedure to implement an I2C slave
No dependency found
var byte tmpstat ; this contains the last sspstat value, on which the user functions are
No documentation 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
Author | Sebastien Lelong, Joep Suijs, Copyright (c) 2008-2009, all rights reserved. |
Adapted-by | Joep Suijs, Albert Faber |
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
16f723 | 16f723_i2c_hw_slave_echo.jal |
16f877a | 16f877a_i2c_hw_slave_echo.jal |
16f88 | 16f88_i2c_hw_slave_echo.jal |
18f14k50 | 18f14k50_i2c_hw_slave_echo.jal |
18f4550 | 18f4550_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
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 |
16f723 | 16f723_i2c_sw_master_echo.jal |
16f723 | 16f723_i2c_sw_master_check_bus.jal |
16f723 | 16f723_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_sw_l1.jal |
16f877a | 16f877a_i2c_sw_master_check_bus.jal |
16f877a | 16f877a_i2c_hw_l1.jal |
16f877a | 16f877a_i2c_sw_master_echo.jal |
16f88 | 16f88_i2c_sw_master_check_bus.jal |
16f88 | 16f88_i2c_sw_l1.jal |
16f88 | 16f88_i2c_sw_master_echo.jal |
18f14k50 | 18f14k50_i2c_hw_l1.jal |
18f14k50 | 18f14k50_i2c_sw_master_check_bus.jal |
18f14k50 | 18f14k50_i2c_sw_master_echo.jal |
18f14k50 | 18f14k50_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_master_check_bus.jal |
18f2450 | 18f2450_i2c_sw_master_echo.jal |
18f4550 | 18f4550_i2c_sw_master_echo.jal |
18f4550 | 18f4550_i2c_hw_l1.jal |
18f4550 | 18f4550_i2c_sw_master_check_bus.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. Define i2c pins like: alias i2c_scl is pin_c3 alias i2c_scl_direction is pin_c3_direction alias i2c_sda is pin_c4 alias i2c_sda_direction is pin_c4_direction const word _i2c_bus_speed = 1 ; * 100kHz TODO:
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 |
16f723 | 16f723_i2c_sw_master_echo.jal |
16f723 | 16f723_i2c_sw_l1.jal |
16f723 | 16f723_i2c_sw_master_check_bus.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 |
18f14k50 | 18f14k50_i2c_sw_master_check_bus.jal |
18f14k50 | 18f14k50_i2c_sw_master_echo.jal |
18f14k50 | 18f14k50_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_master_echo.jal |
18f2450 | 18f2450_i2c_sw_l1.jal |
18f2450 | 18f2450_i2c_sw_master_check_bus.jal |
18f452 | 18f452_24lc256.jal |
18f4550 | 18f4550_i2c_sw_master_echo.jal |
18f4550 | 18f4550_i2c_sw_master_check_bus.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, Joep Suijs |
Compiler | >=2.4g |
This library is used to scan a 4x3 or 4x4 keyboard. To use it, you need to define three variables: keydrive is the half port (_high or _low) with the cols connected. keydrive_direction is the related direction register. keyscan is the half port (_high or _low) with the rows connected. Example: var volatile byte keyscan is porta_low -- rows of keyboard var volatile byte keydrive is portb_low -- columns of keyboard var volatile byte keydrive_direction is portb_low_direction include keyboard Note: if you don't want keyboard.jal change the direction of your pins, make sure all keydrive pins are set to output before you call the library and define: var volatile byte keydrive_direction is keydrive The library has two functions to read the keyboard: getkey() returns the key pressed. getkey_once() returns a pressed key only once (and 'none', 0x10 until the next key is pressed) Hardware setup: connect the keyboard rows to a half port (higher or lower 4 bits of a port) and connect the cols to a half port. Put a pull-down resistor (10k - 47k) on each row pin. Adaptation: soldering your wires in the right order is a lot harder than you think. Make sure you keep the rows and cols together and connect them to right port. You could either adapt your wiring to match the default configuration or reconfigure the library by defining the next 8 constants before you include keyboard.jal, like: const row1 = 0b0000_0100 const row2 = 0b0000_0001 const row3 = 0b0000_0010 const row4 = 0b0000_1000 const col1 = 0b0000_1000 const col2 = 0b0000_0010 const col3 = 0b0000_0100 const col4 = 0b0000_0001 Connect the keyboard and press the buttons. Adapt the row and column constants so pressing the buttons give the right result. Note: you need to specify all 8 constants, even when you have a 4x3 keyboard. In this case you can specify: const col4 = 0b0000_0000 keyboard map (4x4, col4 is left out with 4x3 keyboard) 1 2 3 A row1 4 5 6 B row2 7 8 9 C row3 * 0 # D row4 col 1 2 3 4
No dependency found
var byte lastkey = 0xff
No documentation found
var byte scan0, scan1, scan2, scan3
No documentation found
getkey() return byte
getkey - return the key pressed (until it is released) return: 0 .. 9 numeric key pressed 10 * 11 # 12 .. 15 ??? 16 no key pressed. 17 error (more then one key pressed)
getkey_once() return byte
getkey_once - return the value of a key pressed only once returns: see getkey()
16f876a | 16f876a_keyboard_lcd.jal |
16f877a | 16f877a_keyboard_lcd.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
This is library for creating an array that take up more then 256 bytes memory. Tested on 18F devices only.
Supports byte array with up to 2048 entries Supports word array with up to 1024 entries Supports dword array with up to 512 entries Creates an array named large_array_1 Use "alias new_array_name is large_array_1" to rename the array Small sample of how this lib was created at bottom of lib.
No dependency found
18f452 | 18f452_large_array.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
This is library for creating an array that take up more then 256 bytes memory. Tested on 18F devices only.
Supports byte array with up to 2048 entries Supports word array with up to 1024 entries Supports dword array with up to 512 entries Creates an array named large_array_2 Use "alias new_array_name is large_array_2" to rename the array Small sample of how this lib was created at bottom of lib.
No dependency found
18f452 | 18f452_fat32_sd_card.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
This is library for creating an array that take up more then 256 bytes memory. Tested on 18F devices only.
Supports byte array with up to 2048 entries Supports word array with up to 1024 entries Supports dword array with up to 512 entries Creates an array named large_array_3 Use "alias new_array_name is large_array_3" to rename the array Small sample of how this lib was created at bottom of lib.
No dependency found
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
This is library for creating an array that take up more then 256 bytes memory. Tested on 18F devices only.
Supports byte array with up to 2048 entries Supports word array with up to 1024 entries Supports dword array with up to 512 entries Creates an array named large_array_4 Use "alias new_array_name is large_array_4" to rename the array Small sample of how this lib was created at bottom of lib.
No dependency found
Author | Joep Suijs, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4g |
Provides standard interface to backlight of (directly connected) lcd. First, setup the pin for the backlight: var volatile bit lcd_bl is pin_b0 pin_b0_direction = output If the backlight line is inverted (that is low output turn the backlight on), you must define: const bit lcd_bl_inverted = true If you want digital backlight (on or off), then you can include this library. But if you want variable backlight (256 steps from off to on), the pin above must be a pwm (ccp) output pin. And you have to tell the library, which pwm: const byte lcd_backlight_pwm = 1 now include the library & init it: include lcd_backlight pwm_backlight_init()
No dependency found
pwm_backlight_init()
pwm_backlight_init - init backlight functions
lcd_backlight(bit in onoff)
lcd_backlight - turn backlite on/off
lcd_backlight_variable(byte in value)
lcd_backlight_variable - set backlight level (0 =off, 255 = max on)
16f648a | 16f648a_backlight.jal |
16f877a | 16f877a_backlight.jal |
16f88 | 16f88_backlight.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 | Rob Hamerling, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | 2.4l |
Collection of mathematical routines.
Several authors.
No dependency found
sqrt16(word in x) return byte
Calculate the square root of an unsigned 16-bits integer Returns an 8-bits integer Original author: Kyle York
sqrt32(dword in x) return word
Calculate the square root of an unsigned 32-bits integer Returns a 16-bits integer Original author: Kyle York
16f886 | 16f886_math.jal |
18f14k50 | 18f14k50_sqrt.jal |
18f2450 | 18f2450_sqrt.jal |
18f4550 | 18f4550_sqrt.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
this library provides functions for pata/ide hard disk drives.
"connecting ide drives by tilmann reh" - http://www.gaby.de/gide/IDE-TCJ.txt IDE hardware reference & information document by alex t. ivopol ATA Attachement with Packet Interface 6 - d1410r3-ATA-ATAPI-6.pdf
- If you are not using Alternate Status, Digital Output or Drive Address registers pins cs1 & cs0 can be saved by connecting these ide pins to cs0-high, cs1-low at ide connector. normal operation does not require these pins. Set "CONST BYTE PATA_HD_USE_CS0_CS1_PINS = TRUE" if you will be using these registers - You MUST write full sectors of 512 bytes. - this lib does not do error checking
const PATA_HD_PRECOMP_REG = 9 -- write precomp reg
const PATA_HD_COMMAND_REG = 15 -- command register
const BIT PATA_HD_WAIT_WRITE = 1 -- wait for sector buffer to empty it's contents to disk platters
const PATA_HD_SPIN_DOWN = 0xE0 -- turn off the drive's motor
const dword LARGE_ARRAY_3_SIZE = 512 -- choose number of array variables
const PATA_HD_SEC_COUNT_REG = 10 -- sector count
const PATA_HD_STATUS_REG = 15 -- status register (creates interupt)
const PATA_HD_CYL_HIGH_REG = 13 -- cylinder high
var byte pata_hd_sector_count = 0 -- counds sectors read, must be a byte.
const PATA_HD_RECALIBRATE = 0x10 -- sends drive heads to cyl 0, SC, SN, and SDH are not changed
const PATA_HD_CYL_LOW_REG = 12 -- cylinder low
const PATA_HD_DODC_REG = 16 -- digital output / device control
const PATA_HD_WRITE_SECTORS = 0x30 -- write data to sector(s)
const SD_CARD = 1
const PATA_HD_SEC_NUM_REG = 11 -- sector number
const PATA_HD_ALT_STATUS_REG = 16 -- alternate status (no interupt)
var dword pata_hd_sector_select = 0
const PATA_HD_ADDRESS_REG = 17 -- drive address
const PATA_HARD_DISK = 0 -- data media constants for fat32 lib
const PATA_HD_SDH_REG = 14 -- sector/drive/head register
const PATA_HD_IDENTIFY_DRIVE = 0xEC -- read drive info such as make/modem/sn/drive size
const dword LARGE_ARRAY_3_VARIABLE_SIZE = 1 -- choose size of variables
const DATA_MEDIA = PATA_HARD_DISK
const BIT PATA_HD_WAIT_READ = 0 -- wait for sector buffer to fill it's contents with data from disk platters
var byte pata_hd_word_count = 0 -- counts words read from current sector, must be a byte
const PATA_HD_READ_SECTORS = 0x20 -- reads data from sector(s)
var bit pata_hd_48_bit_lba_support = false -- currently this lib does not support drives > 137,438,952,960 bytes (28 bit addressing)
const PATA_HD_SPIN_UP = 0xE1 -- turn on the drive's motor
const PATA_HD_ERROR_REG = 9 -- error register
const PATA_HD_DATA_REG = 8 -- data register
pata_hd_start_write(dword in address)
pata_hd_write_pulse( byte in z )
pata_hd_data_request(bit in read_write)
pata_hd_go_to_sector(dword in sector, byte in sec_count)
pata_hd_read_data(byte out low_byte, byte out high_byte)
pata_hd_read_sector()
pata_hd_read_pulse(dword in z)
pata_hd_register_read(byte in register, byte out low_byte)
pata_hd_select_register(byte in register)
pata_hd_write_to_sector_end(byte in input_byte)
pata_hd_init()
pata_hd_set_address(byte in pata_hd_head_addr, byte in cyl_high_addr, byte in cyl_low_addr, byte in sec_num_addr, byte in sec_count)
pata_hd_drive_ready()
pata_hd_register_write(byte in register, byte in low_byte)
pata_hd_start_read(dword in address)
pata_hd_write_data(byte in low_byte, byte in high_byte)
pata_hd_busy()
pata_hd_stop_read()
const PATA_HD_PRECOMP_REG = 9 -- write precomp reg
writeable registers
const PATA_HD_COMMAND_REG = 15 -- command register
No documentation found
const BIT PATA_HD_WAIT_WRITE = 1 -- wait for sector buffer to empty it's contents to disk platters
No documentation found
const PATA_HD_SPIN_DOWN = 0xE0 -- turn off the drive's motor
No documentation found
const dword LARGE_ARRAY_3_SIZE = 512 -- choose number of array variables
No documentation found
const PATA_HD_SEC_COUNT_REG = 10 -- sector count
No documentation found
const PATA_HD_STATUS_REG = 15 -- status register (creates interupt)
No documentation found
const PATA_HD_CYL_HIGH_REG = 13 -- cylinder high
No documentation found
var byte pata_hd_sector_count = 0 -- counds sectors read, must be a byte.
No documentation found
const PATA_HD_RECALIBRATE = 0x10 -- sends drive heads to cyl 0, SC, SN, and SDH are not changed
common commands for command register:
const PATA_HD_CYL_LOW_REG = 12 -- cylinder low
No documentation found
const PATA_HD_DODC_REG = 16 -- digital output / device control
No documentation found
const PATA_HD_WRITE_SECTORS = 0x30 -- write data to sector(s)
No documentation found
const SD_CARD = 1
No documentation found
const PATA_HD_SEC_NUM_REG = 11 -- sector number
No documentation found
const PATA_HD_ALT_STATUS_REG = 16 -- alternate status (no interupt)
No documentation found
var dword pata_hd_sector_select = 0
other vars
const PATA_HD_ADDRESS_REG = 17 -- drive address
No documentation found
const PATA_HARD_DISK = 0 -- data media constants for fat32 lib
No documentation found
const PATA_HD_SDH_REG = 14 -- sector/drive/head register
No documentation found
const PATA_HD_IDENTIFY_DRIVE = 0xEC -- read drive info such as make/modem/sn/drive size
No documentation found
const dword LARGE_ARRAY_3_VARIABLE_SIZE = 1 -- choose size of variables
No documentation found
const DATA_MEDIA = PATA_HARD_DISK
No documentation found
const BIT PATA_HD_WAIT_READ = 0 -- wait for sector buffer to fill it's contents with data from disk platters
other constants used for pata_hd_data_request()
var byte pata_hd_word_count = 0 -- counts words read from current sector, must be a byte
variables
const PATA_HD_READ_SECTORS = 0x20 -- reads data from sector(s)
No documentation found
var bit pata_hd_48_bit_lba_support = false -- currently this lib does not support drives > 137,438,952,960 bytes (28 bit addressing)
No documentation found
const PATA_HD_SPIN_UP = 0xE1 -- turn on the drive's motor
No documentation found
const PATA_HD_ERROR_REG = 9 -- error register
readable registers
const PATA_HD_DATA_REG = 8 -- data register
readable/writeable registers
pata_hd_start_write(dword in address)
Get drive ready for writing at specified address
pata_hd_write_pulse( byte in z )
Send a number of write pulses to data register sending 0's as data. Used to get to the end of a sector or to get to a certain location in a sector. Increment pata_hd_word_count
pata_hd_data_request(bit in read_write)
Wait for drive to be ready for a data transfer. Sets data pins as inputs or outputs for next read or write.
pata_hd_go_to_sector(dword in sector, byte in sec_count)
Go to a specific sector number (lba mode only) Max sector number is 268435455 or the number of sectors the drive has. Max drive size is 268435455 * 512 = 137.439 GB Sector count selects number of sectors that will be read Sector count value of 0 means 256 sectors will be read
pata_hd_read_data(byte out low_byte, byte out high_byte)
Read two bytes from disk.
pata_hd_read_sector()
No documentation found
pata_hd_read_pulse(dword in z)
Send a number of read pulses to data register without getting any data. Used to get to the end of a sector or to get to a certain location in a sector. Increment pata_hd_word_count
pata_hd_register_read(byte in register, byte out low_byte)
Select a register and get data from it.
pata_hd_select_register(byte in register)
Set register select pins to selected register, for internal use only.
pata_hd_write_to_sector_end(byte in input_byte)
Finnish writing the current sector with input byte.
pata_hd_init()
initialize startup settings
pata_hd_set_address(byte in pata_hd_head_addr, byte in cyl_high_addr, byte in cyl_low_addr, byte in sec_num_addr, byte in sec_count)
Go to a specific sector, select lba/chs mode and master/slave drive Max sector number is 0x0F_FF_FF_FF or the number of sectors the drive has. Max drive size is 0x0F_FF_FF_FF * 512 = 137.439 GB Sector count selects number of sectors that will be read Sector count value of 0 means 256 sectors will be read
pata_hd_drive_ready()
Wait for drive to be up to speed and ready for a command.
pata_hd_register_write(byte in register, byte in low_byte)
Select a register and give it a command or data.
pata_hd_start_read(dword in address)
Get drive ready for reading at specified address
pata_hd_write_data(byte in low_byte, byte in high_byte)
Write two bytes to disk Data will not be written unless 256 writes are sent.
pata_hd_busy()
Registers may not be accessed unless bsy bit is low due to internal operations.
pata_hd_stop_read()
Tell drive you are done reading
16f877 | 16f877_pata_hard_disk.jal |
18f452 | 18f452_pata_hard_disk.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
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 |
16f877a | 16f877a_data_eeprom.jal |
16f88 | 16f88_data_eeprom.jal |
16f88 | 16f88_remember_me.jal |
18f14k50 | 18f14k50_data_eeprom.jal |
18f242 | 18f242_data_eeprom.jal |
18f2620 | 18f2620_data_eeprom.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
18f452 | 18f452_fat32_sd_card.jal |
18f4550 | 18f4550_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 | Joep Suijs, Copyright (c) 2009..2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4g |
This library provides procedures to profile code parts. Intended for software development, uses timer1.
No dependency found
profiler_report(volatile byte out device)
profiler_start()
profiler_stop()
profiler_stop_and_report(volatile byte in out device)
profiler_setup(byte in resolution)
const byte m2[] = " us"
No documentation found
const byte m1[] = "Profiler "
No documentation found
profiler_report(volatile byte out device)
No documentation found
profiler_start()
No documentation found
profiler_stop()
No documentation found
profiler_stop_and_report(volatile byte in out device)
No documentation found
profiler_setup(byte in resolution)
No documentation found
18f14k50 | 18f14k50_sqrt.jal |
18f2450 | 18f2450_sqrt.jal |
18f4550 | 18f4550_sqrt.jal |
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP1 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP1 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*2 _ccp1con_shadow_dc1b at _ccp1con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr1l_shadow = 0 -- 8 MSbits of duty cycle
var bit*4 _ccp1con_shadow_ccp1m at _ccp1con_shadow : 0 -- mode pattern
var byte _ccp1con_shadow = 0b0000_0000 -- shadow
pwm1_set_percent_dutycycle(byte in percent)
pwm1_on()
pwm1_off()
pwm1_set_dutycycle_lowres(byte in duty)
pwm1_set_dutycycle_highres(word in duty)
pwm1_set_dutycycle(byte in duty)
var bit*2 _ccp1con_shadow_dc1b at _ccp1con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr1l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var bit*4 _ccp1con_shadow_ccp1m at _ccp1con_shadow : 0 -- mode pattern
No documentation found
var byte _ccp1con_shadow = 0b0000_0000 -- shadow
No documentation found
pwm1_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP1_direction should be set to output!
pwm1_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP1_direction should be set to output!
pwm1_off()
PWM mode off retain duty cycle setting in shadow registers
pwm1_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm1_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP1_direction should be set to output!
pwm1_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm1_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP1_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP10 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP10 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var byte _ccpr10l_shadow = 0 -- 8 MSbits of duty cycle
var bit*4 _ccp10con_shadow_ccp10m at _ccp10con_shadow : 0 -- mode pattern
var bit*2 _ccp10con_shadow_dc10b at _ccp10con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccp10con_shadow = 0b0000_0000 -- shadow
pwm10_on()
pwm10_set_dutycycle_lowres(byte in duty)
pwm10_set_dutycycle(byte in duty)
pwm10_set_dutycycle_highres(word in duty)
pwm10_set_percent_dutycycle(byte in percent)
pwm10_off()
var byte _ccpr10l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var bit*4 _ccp10con_shadow_ccp10m at _ccp10con_shadow : 0 -- mode pattern
No documentation found
var bit*2 _ccp10con_shadow_dc10b at _ccp10con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccp10con_shadow = 0b0000_0000 -- shadow
No documentation found
pwm10_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP10_direction should be set to output!
pwm10_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm10_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm10_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP10_direction should be set to output!
pwm10_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP10_direction should be set to output!
pwm10_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP10_direction should be set to output!
pwm10_off()
PWM mode off retain duty cycle setting in shadow registers
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP2 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP2 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*4 _ccp2con_shadow_ccp2m at _ccp2con_shadow : 0 -- mode pattern
var bit*2 _ccp2con_shadow_dc2b at _ccp2con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccp2con_shadow = 0b0000_0000 -- shadow
var byte _ccpr2l_shadow = 0 -- 8 MSbits of duty cycle
pwm2_set_dutycycle(byte in duty)
pwm2_off()
pwm2_set_dutycycle_lowres(byte in duty)
pwm2_on()
pwm2_set_dutycycle_highres(word in duty)
pwm2_set_percent_dutycycle(byte in percent)
var bit*4 _ccp2con_shadow_ccp2m at _ccp2con_shadow : 0 -- mode pattern
No documentation found
var bit*2 _ccp2con_shadow_dc2b at _ccp2con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccp2con_shadow = 0b0000_0000 -- shadow
No documentation found
var byte _ccpr2l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
pwm2_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm2_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP2_direction should be set to output!
pwm2_off()
PWM mode off retain duty cycle setting in shadow registers
pwm2_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm2_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP2_direction should be set to output!
pwm2_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP2_direction should be set to output!
pwm2_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP2_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP3 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP3 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*4 _ccp3con_shadow_ccp3m at _ccp3con_shadow : 0 -- mode pattern
var bit*2 _ccp3con_shadow_dc3b at _ccp3con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr3l_shadow = 0 -- 8 MSbits of duty cycle
var byte _ccp3con_shadow = 0b0000_0000 -- shadow
pwm3_on()
pwm3_set_dutycycle(byte in duty)
pwm3_set_dutycycle_lowres(byte in duty)
pwm3_set_dutycycle_highres(word in duty)
pwm3_set_percent_dutycycle(byte in percent)
pwm3_off()
var bit*4 _ccp3con_shadow_ccp3m at _ccp3con_shadow : 0 -- mode pattern
No documentation found
var bit*2 _ccp3con_shadow_dc3b at _ccp3con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr3l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var byte _ccp3con_shadow = 0b0000_0000 -- shadow
No documentation found
pwm3_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP3_direction should be set to output!
pwm3_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm3_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP3_direction should be set to output!
pwm3_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm3_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP3_direction should be set to output!
pwm3_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP3_direction should be set to output!
pwm3_off()
PWM mode off retain duty cycle setting in shadow registers
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP4 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP4 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var byte _ccp4con_shadow = 0b0000_0000 -- shadow
var bit*2 _ccp4con_shadow_dc4b at _ccp4con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr4l_shadow = 0 -- 8 MSbits of duty cycle
var bit*4 _ccp4con_shadow_ccp4m at _ccp4con_shadow : 0 -- mode pattern
pwm4_set_dutycycle_lowres(byte in duty)
pwm4_off()
pwm4_on()
pwm4_set_percent_dutycycle(byte in percent)
pwm4_set_dutycycle(byte in duty)
pwm4_set_dutycycle_highres(word in duty)
var byte _ccp4con_shadow = 0b0000_0000 -- shadow
No documentation found
var bit*2 _ccp4con_shadow_dc4b at _ccp4con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr4l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var bit*4 _ccp4con_shadow_ccp4m at _ccp4con_shadow : 0 -- mode pattern
No documentation found
pwm4_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm4_off()
PWM mode off retain duty cycle setting in shadow registers
pwm4_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP4_direction should be set to output!
pwm4_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP4_direction should be set to output!
pwm4_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm4_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP4_direction should be set to output!
pwm4_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP4_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP5 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP5 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var byte _ccp5con_shadow = 0b0000_0000 -- shadow
var byte _ccpr5l_shadow = 0 -- 8 MSbits of duty cycle
var bit*2 _ccp5con_shadow_dc5b at _ccp5con_shadow : 4 -- 2 LSbits of duty cycle
var bit*4 _ccp5con_shadow_ccp5m at _ccp5con_shadow : 0 -- mode pattern
pwm5_set_dutycycle_highres(word in duty)
pwm5_set_dutycycle(byte in duty)
pwm5_off()
pwm5_set_dutycycle_lowres(byte in duty)
pwm5_set_percent_dutycycle(byte in percent)
pwm5_on()
var byte _ccp5con_shadow = 0b0000_0000 -- shadow
No documentation found
var byte _ccpr5l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var bit*2 _ccp5con_shadow_dc5b at _ccp5con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var bit*4 _ccp5con_shadow_ccp5m at _ccp5con_shadow : 0 -- mode pattern
No documentation found
pwm5_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP5_direction should be set to output!
pwm5_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm5_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP5_direction should be set to output!
pwm5_off()
PWM mode off retain duty cycle setting in shadow registers
pwm5_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm5_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP5_direction should be set to output!
pwm5_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP5_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP6 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP6 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var byte _ccp6con_shadow = 0b0000_0000 -- shadow
var bit*4 _ccp6con_shadow_ccp6m at _ccp6con_shadow : 0 -- mode pattern
var bit*2 _ccp6con_shadow_dc6b at _ccp6con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr6l_shadow = 0 -- 8 MSbits of duty cycle
pwm6_set_dutycycle_highres(word in duty)
pwm6_on()
pwm6_set_dutycycle_lowres(byte in duty)
pwm6_set_dutycycle(byte in duty)
pwm6_set_percent_dutycycle(byte in percent)
pwm6_off()
var byte _ccp6con_shadow = 0b0000_0000 -- shadow
No documentation found
var bit*4 _ccp6con_shadow_ccp6m at _ccp6con_shadow : 0 -- mode pattern
No documentation found
var bit*2 _ccp6con_shadow_dc6b at _ccp6con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr6l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
pwm6_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP6_direction should be set to output!
pwm6_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP6_direction should be set to output!
pwm6_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm6_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm6_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP6_direction should be set to output!
pwm6_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP6_direction should be set to output!
pwm6_off()
PWM mode off retain duty cycle setting in shadow registers
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP7 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP7 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var byte _ccp7con_shadow = 0b0000_0000 -- shadow
var bit*4 _ccp7con_shadow_ccp7m at _ccp7con_shadow : 0 -- mode pattern
var bit*2 _ccp7con_shadow_dc7b at _ccp7con_shadow : 4 -- 2 LSbits of duty cycle
var byte _ccpr7l_shadow = 0 -- 8 MSbits of duty cycle
pwm7_on()
pwm7_set_dutycycle_lowres(byte in duty)
pwm7_set_percent_dutycycle(byte in percent)
pwm7_off()
pwm7_set_dutycycle_highres(word in duty)
pwm7_set_dutycycle(byte in duty)
var byte _ccp7con_shadow = 0b0000_0000 -- shadow
No documentation found
var bit*4 _ccp7con_shadow_ccp7m at _ccp7con_shadow : 0 -- mode pattern
No documentation found
var bit*2 _ccp7con_shadow_dc7b at _ccp7con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var byte _ccpr7l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
pwm7_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP7_direction should be set to output!
pwm7_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm7_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP7_direction should be set to output!
pwm7_off()
PWM mode off retain duty cycle setting in shadow registers
pwm7_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP7_direction should be set to output!
pwm7_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm7_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP7_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP8 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP8 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*4 _ccp8con_shadow_ccp8m at _ccp8con_shadow : 0 -- mode pattern
var byte _ccpr8l_shadow = 0 -- 8 MSbits of duty cycle
var byte _ccp8con_shadow = 0b0000_0000 -- shadow
var bit*2 _ccp8con_shadow_dc8b at _ccp8con_shadow : 4 -- 2 LSbits of duty cycle
pwm8_set_dutycycle(byte in duty)
pwm8_off()
pwm8_on()
pwm8_set_dutycycle_lowres(byte in duty)
pwm8_set_dutycycle_highres(word in duty)
pwm8_set_percent_dutycycle(byte in percent)
var bit*4 _ccp8con_shadow_ccp8m at _ccp8con_shadow : 0 -- mode pattern
No documentation found
var byte _ccpr8l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
var byte _ccp8con_shadow = 0b0000_0000 -- shadow
No documentation found
var bit*2 _ccp8con_shadow_dc8b at _ccp8con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
pwm8_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm8_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP8_direction should be set to output!
pwm8_off()
PWM mode off retain duty cycle setting in shadow registers
pwm8_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP8_direction should be set to output!
pwm8_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
pwm8_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP8_direction should be set to output!
pwm8_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP8_direction should be set to output!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling. |
Compiler | 2.4l |
Performs PWM operations on the CCP9 module. This file is automatically included by pwm_hardware.jal when the target PIC has a CCP9 module.
1. This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib) 2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171. Reduced memory occupation. Added procedure for lowres PWM.
No dependency found
var bit*2 _ccp9con_shadow_dc9b at _ccp9con_shadow : 4 -- 2 LSbits of duty cycle
var bit*4 _ccp9con_shadow_ccp9m at _ccp9con_shadow : 0 -- mode pattern
var byte _ccp9con_shadow = 0b0000_0000 -- shadow
var byte _ccpr9l_shadow = 0 -- 8 MSbits of duty cycle
pwm9_set_dutycycle(byte in duty)
pwm9_set_percent_dutycycle(byte in percent)
pwm9_set_dutycycle_highres(word in duty)
pwm9_on()
pwm9_off()
pwm9_set_dutycycle_lowres(byte in duty)
var bit*2 _ccp9con_shadow_dc9b at _ccp9con_shadow : 4 -- 2 LSbits of duty cycle
No documentation found
var bit*4 _ccp9con_shadow_ccp9m at _ccp9con_shadow : 0 -- mode pattern
No documentation found
var byte _ccp9con_shadow = 0b0000_0000 -- shadow
No documentation found
var byte _ccpr9l_shadow = 0 -- 8 MSbits of duty cycle
No documentation found
pwm9_set_dutycycle(byte in duty)
Set dutycycle for 10-bits resolution but allowing only 255 PWM steps. This procedure is equivalent to pwm9_set_dutycycle_highres(), but the low order 2 bits of the 10-bits duty cycle are set to 0. This means that only every 4th of the available 1023 steps can be selected and consequently max 255 PWM steps are available. This procedure is for user convenience, allowing to specify an 8 bits value for the duty cycle is for many applications satisfactory. Calling this procedure will also activate PWM. Note: pin_CCP9_direction should be set to output!
pwm9_set_percent_dutycycle(byte in percent)
Set a percentage duty cycle, allowing max 100 PWM steps. Allowed range: 0..100 The duty cycle will be set to the specified percentage of the maximum for the current PWM frequency. Note: The number of available PWM steps can be lower than 100 with (very) high PWM frequencies. Note: pin_CCP9_direction should be set to output!
pwm9_set_dutycycle_highres(word in duty)
Set dutycycle with 10-bits resolution, allowing 1024 PWM steps. The 'duty' argument is a (max) 10-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<9:2> are the 8 MSbits Allowed range: 0..1023 Note: pin_CCP9_direction should be set to output!
pwm9_on()
PWM mode on Restore duty cycle from shadow registers Note: pin_CCP9_direction should be set to output!
pwm9_off()
PWM mode off retain duty cycle setting in shadow registers
pwm9_set_dutycycle_lowres(byte in duty)
Set dutycycle with 8-bits resolution allowing 255 PWM steps. The 'duty' argument is the 8-bits absolute value for the duty cycle: * duty<1:0> are the 2 LSbits * duty<7:2> are the 6 MSbits Allowed range: 0..255 Beware that steps 256..1023 are not available. In other words the available PWM range is 25% of the highres procedure. This procedure is particularly suitable with higher frequencies whereby the PWM resolution is limited to 256 steps or less!
Author | Stef Mientki, Copyright (C) 2002-2006, all rights reserved. |
Adapted-by | Sebastien Lelong |
Compiler | 2.4l |
This lib handles common operations on PWM, regardless the channel number. It is used in combination with one or more pwm_ccplibraries (eg. pwm_ccp1.jal, pwm_ccp2.jal, etc.). These libraries are included automatically dependent of the configuration of the target PIC.
This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib).
No dependency found
var volatile word _pr2_shadow_plus1 = 256 -- value(PR2) + 1
Shadow of PR2 (value incremented by 1, i.e. value in range 1..256)
pwm_max_resolution(byte in prescaler)
Sets all(!) CCP modules for max (10-bits) PWM resolution. While setting maximum resolution, the Timer2 prescaler can be used to adjust frequency to a some extent with the Timer2 parameter value which can be either: * 1 : high frequency * 4 : medium frequency * 16: low frequency Below a table showing the PWM frequencies for common clock speeds and different Timer2 prescaler values. ||*Timer2 prescaler* || *4MHz* || *8MHz* || *10MHz* || *20MHz* || || 1 || 3.90 kHz || 7.81 kHz || 9.77 kHz || 19.43 kHz || || 4 || 976 Hz || 1.95 kHz || 2.44 kHz || 4.88 kHz || || 16 || 244 Hz || 488 Hz || 610 Hz || 1.22 kHz || For PICs with more than one CCP module you should realize that all CCP modules use Timer2 and PR2 for PWM operations. This means that the PWM period (frequency) of all PWM output pins is the same. Only the duty cycle can vary between one and another PWM pin. Set PWM to maximum resolution (for all PWM pins!). This implies 1 out of 3 specific PWM frequencies, depending on the Timer2 prescaler value passed with the call. See examples in the table above, or use the formula in the datasheet to calculate the resulting frequency.
pwm_set_frequency(dword in freq)
Sets all(!) CCP modules for a specific PWM frequency. The minimum and maximum allowed PWM frequencies depend on the clock speed. When specifying a value beyond the limits PWM will not be started. The chosen frequency may enforce a limit on the PWM resolution (number of steps). The application program should not specify a higher value for the duty cycle than this limit. When exceeding this limit the dutycycle will probably result in a 'weird' value. Only the procedure set_dutycycle_percent() is safe in this case, the other set_dutycycle procedures use absolute values and are not safe!
Author | Sebastien Lelong, Copyright (C) 2008-2009, all rights reserved. |
Adapted-by | Albert Faber, Rob Hamerling. |
Compiler | 2.4l |
Include this library if you want to use the PWM feature of the CCP module(s). This library uses conditional compile to selectively include underlying PWM libraries and number of PWM channels, according to the target PIC configuration. Ex: - 16f88 has 1 PWM channel: including pwm_hardware will prepare PWM for 1 channel (using pwm_ccp1.jal) - 16f877 has 2 PWM channels: including pwm_hardware will prepare PWM for 2 channels (using pwm_ccp1.jal and pwm_ccp2.jal) - etc. for PICs with more CCP modules Note: All used pin_CCPx_directions should be set to output by the application. With using the PWM hardware a design choice must be made between desired PWM frequency and desired PWM resolution (number of possible PWM steps). Choosing maximum PWM resolution implies a relative low PWM frequency and vice versa: a high frequency limits the number of available PWM steps. The figures are dependent on the target clock speed. Refer to pwm_common, pwm_ccp1, pwm_ccp2 ... etc. documentation to understand how to use these PWM libraries.
1. Because the PWM libraries use conditional compilation and the 'alias' keyword, at least JalV2 compiler version 2.4l is required. 2. These libraries use the pin alias names as declared in Jallib device files since revision 1171, so Jallib release 0.4 is a minimum requirement. 3. Some PICs have extended CCP modules. These will be handled by these PWM libraries as 'classic' CCP modules.
12f683 | 12f683_pwm_adc.jal |
16f723 | 16f723_pwm_sound.jal |
16f723 | 16f723_pwm_led_highres.jal |
16f723 | 16f723_pwm_led.jal |
16f767 | 16f767_pwm_adc.jal |
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 |
16f886 | 16f886_pwm_adc_res.jal |
16f886 | 16f886_pwm_adc_freq.jal |
18f14k50 | 18f14k50_pwm_sound.jal |
18f14k50 | 18f14k50_pwm_led.jal |
18f14k50 | 18f14k50_pwm_led_highres.jal |
18f2450 | 18f2450_pwm_led_highres.jal |
18f2450 | 18f2450_pwm_sound.jal |
18f2450 | 18f2450_pwm_led.jal |
18f4550 | 18f4550_pwm_led_highres.jal |
18f4550 | 18f4550_pwm_sound.jal |
18f4550 | 18f4550_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 (depricated, use queue1_is_empty()) queue01_is_empty() -- returns true if queue is emtpy queue01_is_full() -- returns true if queue is full queue01_nr_free() -- returns nr of free places in queue queue01_nr_used() -- returns nr of used places in queue
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'get() return byte
queue01_empty() return bit
queue01_is_empty() return bit
queue01_nr_free() return byte
queue01_nr_used() return byte
queue01_is_full() return bit
queue01_nb_put(byte in v) return bit
queue01_nb'get() return byte
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()
deprecated
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_empty() return bit
queue01_is_empty() return bit
queue01_is_empty() -- returns true if queue is emtpy
queue01_nr_free() return byte
queue01_nr_free - returns nr of free places in queue
queue01_nr_used() return byte
queue01_nr_used - returns nr of used places in queue
queue01_is_full() return bit
queue01_is_full() -- returns true if queue is full
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_nb'get() return byte
queue01_nb'get - get one byte from queue (non-blocking) returns byte from queue, 0 if queue empty
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)
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: queue02 = x -- put x into queue; block if queue is full x = queue02 -- read x from queue; block if queue is empty non-blocking access to the same queue is provided by queue02_nb_put() and queue02_nb_get() other methods: queue02_clear() -- clear queue (makes queue empty) queue02_empty() -- returns true if queue is emtpy (depricated, use queue1_is_empty()) queue02_is_empty() -- returns true if queue is emtpy queue02_is_full() -- returns true if queue is full queue02_nr_free() -- returns nr of free places in queue queue02_nr_used() -- returns nr of used places in queue
No dependency found
var volatile byte queue02_in_pointer = 0 ; wijst naar vrije locatie
var volatile byte queue02_out_pointer = 0 ; wijst naar databyte
var volatile byte queue02_data[queue02_size + 1]
queue02_is_full() return bit
queue02_empty() return bit
queue02'get() return byte
queue02_nb'get() return byte
queue02_is_empty() return bit
queue02_nb_get(byte out v) return bit
queue02_nb_put(byte in v) return bit
queue02_nr_used() return byte
queue02_nr_free() return byte
var volatile byte queue02_in_pointer = 0 ; wijst naar vrije locatie
No documentation found
var volatile byte queue02_out_pointer = 0 ; wijst naar databyte
No documentation found
var volatile byte queue02_data[queue02_size + 1]
queue vars
queue02_nb'put(byte in v)
queue02_nb'put - put one byte into queue (non-blocking)
queue02_clear()
deprecated
queue02'put(byte in v)
queue02'put - put one byte into queue When the queue is full, it waits until a byte is removed from the queue.
queue02_is_full() return bit
queue02_is_full() -- returns true if queue is full
queue02_empty() return bit
queue02'get() return byte
queue02'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.
queue02_nb'get() return byte
queue02_nb'get - get one byte from queue (non-blocking) returns byte from queue, 0 if queue empty
queue02_is_empty() return bit
queue02_is_empty() -- returns true if queue is emtpy
queue02_nb_get(byte out v) return bit
queue02_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)
queue02_nb_put(byte in v) return bit
queue02_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)
queue02_nr_used() return byte
queue02_nr_used - returns nr of used places in queue
queue02_nr_free() return byte
queue02_nr_free - returns nr of free places in queue
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: queue03 = x -- put x into queue; block if queue is full x = queue03 -- read x from queue; block if queue is empty non-blocking access to the same queue is provided by queue03_nb_put() and queue03_nb_get() other methods: queue03_clear() -- clear queue (makes queue empty) queue03_empty() -- returns true if queue is emtpy (depricated, use queue1_is_empty()) queue03_is_empty() -- returns true if queue is emtpy queue03_is_full() -- returns true if queue is full queue03_nr_free() -- returns nr of free places in queue queue03_nr_used() -- returns nr of used places in queue
No dependency found
var volatile byte queue03_in_pointer = 0 ; wijst naar vrije locatie
var volatile byte queue03_out_pointer = 0 ; wijst naar databyte
var volatile byte queue03_data[queue03_size + 1]
queue03_nr_free() return byte
queue03'get() return byte
queue03_nr_used() return byte
queue03_nb_put(byte in v) return bit
queue03_is_full() return bit
queue03_nb'get() return byte
queue03_nb_get(byte out v) return bit
queue03_is_empty() return bit
queue03_empty() return bit
var volatile byte queue03_in_pointer = 0 ; wijst naar vrije locatie
No documentation found
var volatile byte queue03_out_pointer = 0 ; wijst naar databyte
No documentation found
var volatile byte queue03_data[queue03_size + 1]
queue vars
queue03'put(byte in v)
queue03'put - put one byte into queue When the queue is full, it waits until a byte is removed from the queue.
queue03_clear()
deprecated
queue03_nb'put(byte in v)
queue03_nb'put - put one byte into queue (non-blocking)
queue03_nr_free() return byte
queue03_nr_free - returns nr of free places in queue
queue03'get() return byte
queue03'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.
queue03_nr_used() return byte
queue03_nr_used - returns nr of used places in queue
queue03_nb_put(byte in v) return bit
queue03_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)
queue03_is_full() return bit
queue03_is_full() -- returns true if queue is full
queue03_nb'get() return byte
queue03_nb'get - get one byte from queue (non-blocking) returns byte from queue, 0 if queue empty
queue03_nb_get(byte out v) return bit
queue03_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)
queue03_is_empty() return bit
queue03_is_empty() -- returns true if queue is emtpy
queue03_empty() return bit
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: queue04 = x -- put x into queue; block if queue is full x = queue04 -- read x from queue; block if queue is empty non-blocking access to the same queue is provided by queue04_nb_put() and queue04_nb_get() other methods: queue04_clear() -- clear queue (makes queue empty) queue04_empty() -- returns true if queue is emtpy (depricated, use queue1_is_empty()) queue04_is_empty() -- returns true if queue is emtpy queue04_is_full() -- returns true if queue is full queue04_nr_free() -- returns nr of free places in queue queue04_nr_used() -- returns nr of used places in queue
No dependency found
var volatile byte queue04_in_pointer = 0 ; wijst naar vrije locatie
var volatile byte queue04_out_pointer = 0 ; wijst naar databyte
var volatile byte queue04_data[queue04_size + 1]
queue04_nr_free() return byte
queue04_empty() return bit
queue04_is_full() return bit
queue04_nb'get() return byte
queue04_nr_used() return byte
queue04_is_empty() return bit
queue04_nb_get(byte out v) return bit
queue04'get() return byte
queue04_nb_put(byte in v) return bit
var volatile byte queue04_in_pointer = 0 ; wijst naar vrije locatie
No documentation found
var volatile byte queue04_out_pointer = 0 ; wijst naar databyte
No documentation found
var volatile byte queue04_data[queue04_size + 1]
queue vars
queue04'put(byte in v)
queue04'put - put one byte into queue When the queue is full, it waits until a byte is removed from the queue.
queue04_nb'put(byte in v)
queue04_nb'put - put one byte into queue (non-blocking)
queue04_clear()
deprecated
queue04_nr_free() return byte
queue04_nr_free - returns nr of free places in queue
queue04_empty() return bit
queue04_is_full() return bit
queue04_is_full() -- returns true if queue is full
queue04_nb'get() return byte
queue04_nb'get - get one byte from queue (non-blocking) returns byte from queue, 0 if queue empty
queue04_nr_used() return byte
queue04_nr_used - returns nr of used places in queue
queue04_is_empty() return bit
queue04_is_empty() -- returns true if queue is emtpy
queue04_nb_get(byte out v) return bit
queue04_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)
queue04'get() return byte
queue04'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.
queue04_nb_put(byte in v) return bit
queue04_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)
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 |
16f723 | 16f723_random.jal |
16f877a | 16f877a_random.jal |
16f88 | 16f88_random.jal |
18f14k50 | 18f14k50_random.jal |
18f2450 | 18f2450_random.jal |
18f4550 | 18f4550_random.jal |
Author | Eur van Andel, Copyright (c) 2003..2008, all rights reserved. |
Adapted-by | Rob Hamerling |
Compiler | 2.4l |
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. At 20 MHz, so 200ns/clock, so 5 000 000 clocks/second Rhe RTC has three bytes: bres_hi, bres_mid, bres_lo timer 0 runs on internal clock speed and interrupts on overflow every timer 0 interrupt decreases bres_mid by one. The 2 000 000 value is added when bres_hi en bres_mid are zero note that remainder is added to bres_lo, which can overflow in bres_mid this keeps clock count accurate, although interrupts happen every 256 clock counts the ISR subtracts 1 from the mid byte. It first checks the mid byte for zero and borrows a bit from bres_hi if needed. Required PIC settings: OPTION_REG_PSA = 1 OPTION_REG_PS = 0 OPTION_REG_T0CS = 0 -- Timer0 on instruction cycle clock
No dependency found
var volatile byte _rtc_bres_mid = _rtc_mid -- > init 3-byte counter
const byte _rtc_mid = _rtc_cycles_per_second % 65536 / 256
const byte _rtc_hi = _rtc_cycles_per_second / 65536
var volatile byte _rtc_bres_hi = _rtc_hi -- \
var volatile byte _rtc_bres_lo = _rtc_lo -- /
const _rtc_cycles_per_second = (target_clock / 4)
var volatile byte seconds -- global variable updated by ISR
const byte _rtc_lo = _rtc_cycles_per_second % 256
var volatile byte _rtc_bres_mid = _rtc_mid -- > init 3-byte counter
No documentation found
const byte _rtc_mid = _rtc_cycles_per_second % 65536 / 256
No documentation found
const byte _rtc_hi = _rtc_cycles_per_second / 65536
No documentation found
var volatile byte _rtc_bres_hi = _rtc_hi -- \
No documentation found
var volatile byte _rtc_bres_lo = _rtc_lo -- /
No documentation found
const _rtc_cycles_per_second = (target_clock / 4)
No documentation found
var volatile byte seconds -- global variable updated by ISR
No documentation found
const byte _rtc_lo = _rtc_cycles_per_second % 256
No documentation found
RTC()
No documentation found
16f876a | 16f876a_rtc_lcd.jal |
16f877a | 16f877a_rtc_lcd.jal |
16f886 | 16f886_rtc_lcd_4mhz.jal |
16f886 | 16f886_rtc_lcd_20mhz.jal |
16f886 | 16f886_rtc_lcd_125khz.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
this library provides functions for SD memory cards.
SanDisk Secure Digital Card - http://www.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf How to use MMC/SDC - http://forums.parallax.com/forums/attach.aspx?a=32012
This version works with only standard capacity sd cards up to 4gb, high capacity up to 32 gb, and Extended Capacity up to 2TB may be supported later on.
const byte SD_SEND_NUM_WR_BLOCKS = 22
const byte SD_PROGRAM_CSD = 27
const dword LARGE_ARRAY_4_SIZE = 512 -- choose number of array variables
const byte SD_STOP_TRANSMISSION = 12
const byte SD_WRITE_MULTIPLE_BLOCK = 25
const byte SD_SEND_SCR = 51
const byte SD_CLR_WRITE_PROT = 29
const byte SD_APP_CMD = 55 -- indicate that the next command is a application specific command
const byte SD_GO_IDLE_STATE = 0
const byte SD_SET_BLOCKLEN = 16
const byte SD_SET_WR_BLK_ERASE_COUNT = 23
const byte SD_SD_STATUS = 13
const byte SD_READ_SINGLE_BLOCK = 17
const byte SD_SEND_OP_COND = 1
const PATA_HARD_DISK = 0
const byte SD_SEND_CID = 10
const byte SD_GEN_CMD = 56
const byte SD_SEND_WRITE_PROT = 30
const byte SD_ERASE_WR_BLK_END = 33
var word sd_sector_count = 0
const byte SD_READ_MULTIPLE_BLOCK = 18
const byte SD_ERASE_WR_BLK_START = 32
const SD_CARD = 1
const byte SD_ERASE = 38
const byte SD_SD_APP_OP_COND = 41
const byte SD_WRITE_BLOCK = 24
var byte sd_word_count = 0
const byte SD_CRC_ON_OFF = 59 -- default is off
const byte SD_SET_WRITE_PROT = 28
const dword LARGE_ARRAY_4_VARIABLE_SIZE = 1 -- choose size of variables
const byte SD_READ_OCR = 58
const DATA_MEDIA = SD_CARD
const byte SD_SEND_STATUS = 13
const byte SD_SEND_CSD = 9 -- sd sends "Card Specific Data" standard or high capacity
const byte SD_SET_CLR_CARD_DETECT = 42
sd_ready()
sd_write_to_sector_end(byte in input_byte)
sd_init()
sd_stop_read()
sd_write_pulse(byte in count1)
send_command(byte in command,dword in data, byte out response)
sd_read_sector()
sd_read_data(byte out low_byte, byte out high_byte)
sd_stop_write()
sd_set_idle()
sd_read_pulse(byte in count1)
sd_start_read(dword in address)
sd_start_write(dword in address)
sd_write_data(byte in low_byte, byte in high_byte)
const byte SD_SEND_NUM_WR_BLOCKS = 22
No documentation found
const byte SD_PROGRAM_CSD = 27
No documentation found
const dword LARGE_ARRAY_4_SIZE = 512 -- choose number of array variables
No documentation found
const byte SD_STOP_TRANSMISSION = 12
No documentation found
const byte SD_WRITE_MULTIPLE_BLOCK = 25
No documentation found
const byte SD_SEND_SCR = 51
No documentation found
const byte SD_CLR_WRITE_PROT = 29
No documentation found
const byte SD_APP_CMD = 55 -- indicate that the next command is a application specific command
Application Specific Commands
const byte SD_GO_IDLE_STATE = 0
Basic Commands
const byte SD_SET_BLOCKLEN = 16
Read Commands
const byte SD_SET_WR_BLK_ERASE_COUNT = 23
No documentation found
const byte SD_SD_STATUS = 13
application specific command, must write command 55 first
const byte SD_READ_SINGLE_BLOCK = 17
No documentation found
const byte SD_SEND_OP_COND = 1
No documentation found
const PATA_HARD_DISK = 0
constants for fat32 library
const byte SD_SEND_CID = 10
No documentation found
const byte SD_GEN_CMD = 56
No documentation found
const byte SD_SEND_WRITE_PROT = 30
No documentation found
const byte SD_ERASE_WR_BLK_END = 33
No documentation found
var word sd_sector_count = 0
No documentation found
const byte SD_READ_MULTIPLE_BLOCK = 18
No documentation found
const byte SD_ERASE_WR_BLK_START = 32
Erase Commands
const SD_CARD = 1
No documentation found
const byte SD_ERASE = 38
No documentation found
const byte SD_SD_APP_OP_COND = 41
No documentation found
const byte SD_WRITE_BLOCK = 24
Write Commands
var byte sd_word_count = 0
counters
const byte SD_CRC_ON_OFF = 59 -- default is off
No documentation found
const byte SD_SET_WRITE_PROT = 28
Write Protection Commands
const dword LARGE_ARRAY_4_VARIABLE_SIZE = 1 -- choose size of variables
No documentation found
const byte SD_READ_OCR = 58
Other Commands
const DATA_MEDIA = SD_CARD
No documentation found
const byte SD_SEND_STATUS = 13
No documentation found
const byte SD_SEND_CSD = 9 -- sd sends "Card Specific Data" standard or high capacity
No documentation found
const byte SD_SET_CLR_CARD_DETECT = 42
No documentation found
sd_ready()
No documentation found
sd_write_to_sector_end(byte in input_byte)
No documentation found
sd_init()
No documentation found
sd_stop_read()
No documentation found
sd_write_pulse(byte in count1)
No documentation found
send_command(byte in command,dword in data, byte out response)
No documentation found
sd_read_sector()
No documentation found
sd_read_data(byte out low_byte, byte out high_byte)
No documentation found
sd_stop_write()
No documentation found
sd_set_idle()
No documentation found
sd_read_pulse(byte in count1)
No documentation found
sd_start_read(dword in address)
No documentation found
sd_start_write(dword in address)
No documentation found
sd_write_data(byte in low_byte, byte in high_byte)
No documentation found
16f877 | 16f877_sd_card.jal |
18f452 | 18f452_sd_card.jal |
18f452 | 18f452_fat32_sd_card.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.
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
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 alias 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)
16f648a | 16f648a_serial_hw_int_cts.jal |
16f723 | 16f723_serial_hw_int_cts.jal |
16f877a | 16f877a_serial_hw_int_cts.jal |
16f88 | 16f88_serial_hw_int_cts.jal |
16f88 | 16f88_serial_hw_int_cts_echo.jal |
18f14k50 | 18f14k50_serial_hw_int_cts.jal |
18f2450 | 18f2450_serial_hw_int_cts.jal |
18f4550 | 18f4550_serial_hw_int_cts.jal |
Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Albert Faber |
Compiler | >=2.4l |
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 are disabled during transmissions. Transmission parameters are 8 databits, 2 stopbits, no parity, no handshake. const serial_sw_stopbits = 1 ; setup for one stopbit.
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 | Wouter van Ooijen (c) 1998, all rights reserved. |
Adapted-by | Joep Suijs, Vasile Surducan 25.08.2009 |
Compiler | >=2.2 |
Translation routine for 7 segment display. The seven segment display needs to be connected to a single port. Define the pin layout of the seven segment display like: constant for the segments gfe dcba const byte seven_segment_a = 0b_0000_0001 const byte seven_segment_b = 0b_0000_0010 const byte seven_segment_c = 0b_0000_0100 const byte seven_segment_d = 0b_0000_1000 const byte seven_segment_e = 0b_0001_0000 const byte seven_segment_f = 0b_0010_0000 const byte seven_segment_g = 0b_0100_0000 const byte seven_segment_dp = 0b_1000_0000 character set: value 0 is character 0 value 1 is character 1 value 2 is character 2 value 3 is character 3 value 4 is character 4 value 5 is character 5 value 6 is character 6 value 7 is character 7 value 8 is character 8 value 9 is character 9 value 10 is character A value 11 is character b value 12 is character C_big value 13 is character d value 14 is character E value 15 is character F value 16 is character S value 17 is character c_small value 18 is character r value 19 is character H value 20 is character i_small value 21 is character L value 22 is character o value 23 is character P value 24 is character U_big value 26 is character u value 27 is character space Use: const bit seven_segment_common_anode = true ; omit this line if you use a common cathode display. portd_direction = all_output portd = seven_from_digit(1) -- display '1'
No dependency found
const byte seven_value_space[] = {
No documentation found
seven_from_digit( byte in x ) return byte
return seven segment value corresponding to lower nibble of x
16f877a | 16f877a_seven_segment.jal |
18f4550 | 18f4550_seven_segment.jal |
Author | William Welch Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | 2.4l |
SPI Master hardware control. Routines for sending and receiving through the SPI in master mode
good overview of SPI at http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus also at: http://elm-chan.org/docs/spi_e.html
No dependency found
const SPI_MODE_01 = 1
const SPI_RATE_FOSC_4 = 0
const SPI_RATE_FOSC_16 = 1
const SPI_MODE_10 = 2
const SPI_RATE_TMR = 3
const SPI_MODE_00 = 0
const SPI_MODE_11 = 3
const SPI_RATE_FOSC_64 = 2
const SPI_MODE_01 = 1
No documentation found
const SPI_RATE_FOSC_4 = 0
Use these when calling the spi_init() routine below ( SPI clock frequency )
const SPI_RATE_FOSC_16 = 1
No documentation found
const SPI_MODE_10 = 2
No documentation found
const SPI_RATE_TMR = 3
No documentation found
const SPI_MODE_00 = 0
Use these when calling the spi_init() routine below ( SPI master mode, see sources above )
const SPI_MODE_11 = 3
No documentation found
const SPI_RATE_FOSC_64 = 2
No documentation found
spi_master_hw'put(byte in data)
half-duplex convenience function. send data to slave, discard reply
spi_init(byte in spi_mode, byte in spi_rate)
Initialize the SPI registers. Note: check your datasheet -- TRIS settings, any SPI errata?
spi_master_hw_exchange(byte in m_data) return byte
SPI is full-duplex, so we exchange master and slave data byte
spi_master_hw'get() return byte
half-duplex convenience function. send 0xFF, get slave data
16f877 | 16f877_23k256.jal |
16f877 | 16f877_sd_card.jal |
18f452 | 18f452_sd_card.jal |
18f452 | 18f452_fat32_pata_hard_disk.jal |
18f452 | 18f452_23k256.jal |
18f452 | 18f452_fat32_sd_card.jal |
Author | Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4l |
This is library for 23K256 SPI SRAM, Microchip's 20mhz 256kbit SRAM memory
http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf
Address from 0 to 32,767 This is a 2.7v to 3.6v memory. This lib should also work with 23k640 (64kbit sram), but hasn't been tested, please let me know. Also should work with 23A640 & 23A256 (1.5v to 1.95v versions), also not tested SPI Mode is 00 for 23k256
No dependency found
const byte SRAM_23K256_ALWAYS_SET_SPI_MODE = TRUE
const byte SRAM_23K256_WRITE_COMMAND = 0b_0000_0010 -- Write data to memory array beginning at selected address
const byte SRAM_23K256_READ_STATUS = 0b_0000_0101 -- Read STATUS register
const byte SRAM_23K256_READ_COMMAND = 0b_0000_0011 -- Read data from memory array beginning at selected address
const byte SRAM_23K256_WRITE_SETTINGS = 0b_0000_0001 -- Write STATUS register
const byte SRAM_23K256_SEQUENTIAL_MODE = 0b01 -- send read command then read many bytes
const byte SRAM_23K256_BYTE_MODE = 0b00 -- read only one byte
const byte SRAM_23K256_HOLD_ENABLE = 0 -- enable the hold pin (conect pin to microcontroller)
const byte SRAM_23K256_PAGE_MODE = 0b10 -- send read command then read 1 32Byte page
const byte SRAM_23K256_HOLD_DISABLE = 1 -- disable the hold pin. (connect put pin direct to 3.3v)
sram_23k256_start_write(word in address)
sram_23k256_init(byte in sram_23k256_mode, byte in sram_23k256_hold_disable)
sram_23k256_byte'put(word in address, byte in data)
sram_23k256_do_read(byte out data)
sram_23k256_dword'put(word in address, dword in data)
sram_23k256_read_settings(byte out mode, byte out hold_is_disabled)
sram_23k256_do_write(byte in data)
sram_23k256_word'put(word in address, word in data)
sram_23k256_write(word in address, byte in data)
sram_23k256_read(word in address, byte out data)
sram_23k256_stop_read()
sram_23k256_start_read(word in address)
sram_23k256_stop_write()
sram_23k256_dword'get(word in address) return dword
sram_23k256_word'get(word in address) return word
sram_23k256_byte'get(word in address) return byte
const byte SRAM_23K256_ALWAYS_SET_SPI_MODE = TRUE
No documentation found
const byte SRAM_23K256_WRITE_COMMAND = 0b_0000_0010 -- Write data to memory array beginning at selected address
No documentation found
const byte SRAM_23K256_READ_STATUS = 0b_0000_0101 -- Read STATUS register
No documentation found
const byte SRAM_23K256_READ_COMMAND = 0b_0000_0011 -- Read data from memory array beginning at selected address
constants for internal usage
const byte SRAM_23K256_WRITE_SETTINGS = 0b_0000_0001 -- Write STATUS register
No documentation found
const byte SRAM_23K256_SEQUENTIAL_MODE = 0b01 -- send read command then read many bytes
No documentation found
const byte SRAM_23K256_BYTE_MODE = 0b00 -- read only one byte
constants for use with init procedure input data modes in witch to read and write data
const byte SRAM_23K256_HOLD_ENABLE = 0 -- enable the hold pin (conect pin to microcontroller)
No documentation found
const byte SRAM_23K256_PAGE_MODE = 0b10 -- send read command then read 1 32Byte page
No documentation found
const byte SRAM_23K256_HOLD_DISABLE = 1 -- disable the hold pin. (connect put pin direct to 3.3v)
No documentation found
sram_23k256_start_write(word in address)
get 23K256 ready for writing and select a address to start from (fast writes) do not interupt read process by switching to another spi device
sram_23k256_init(byte in sram_23k256_mode, byte in sram_23k256_hold_disable)
initialize startup settings & spi mode 00
sram_23k256_byte'put(word in address, byte in data)
Write to 23k256 as a byte array
sram_23k256_do_read(byte out data)
read byte from the 23K256
sram_23k256_dword'put(word in address, dword in data)
Write 23k256 as a large 8K dword array
sram_23k256_read_settings(byte out mode, byte out hold_is_disabled)
Reads the status/settings register to get the current 23k256 mode that was previously set in the init procedure. SRAM_23K256_BYTE_MODE, SRAM_23K256_SEQUENTIAL_MODE, SRAM_23K256_PAGE_MODE
sram_23k256_do_write(byte in data)
write byte to the 23K256 you may use spi_master_hw directly instead.
sram_23k256_word'put(word in address, word in data)
Write 23k256 as a large 16K word array
sram_23k256_write(word in address, byte in data)
Write 1 byte to selected address
sram_23k256_read(word in address, byte out data)
Read 1 byte to selected address
sram_23k256_stop_read()
tell 23K256 you are finished reading
sram_23k256_start_read(word in address)
get 23K256 ready for reading and select a address to start from (fast reads) do not interupt read process by switching to another spi device
sram_23k256_stop_write()
tell 23K256 you are finished writing
sram_23k256_dword'get(word in address) return dword
Read from 23k256 as a large 8K dword array
sram_23k256_word'get(word in address) return word
Read from 23k256 as a large 16K word array
sram_23k256_byte'get(word in address) return byte
Read from 23k256 as a byte array
16f877 | 16f877_23k256.jal |
18f452 | 18f452_fat32_sd_card.jal |
18f452 | 18f452_23k256.jal |
18f452 | 18f452_fat32_pata_hard_disk.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.
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 |
16f723 | 16f723_timer0_interval.jal |
Author | Sebastien Lelong, Copyright (c) 2009, all rights reserved. |
Adapted-by | |
Compiler | >=2.4k |
set of procedures used to perform unittest
No dependency found
test_dword(dword in t)
test_byte(byte in t)
test_sdword(sdword in t)
test_word(word in t)
test_sword(sword in t)
test_bit(bit in t)
test_dword(dword in t)
No documentation found
test_byte(byte in t)
No documentation found
test_sdword(sdword in t)
No documentation found
test_word(word in t)
No documentation found
test_sword(sword in t)
No documentation found
test_bit(bit in t)
No documentation found
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
18f14k50 | 18f14k50_usb_hid_mouse.jal |
18f14k50 | 18f14k50_usb_hid_generic.jal |
18f14k50 | 18f14k50_usb_bootloader_autostart.jal |
18f14k50 | 18f14k50_usb_bootloader.jal |
18f14k50 | 18f14k50_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_bootloader.jal |
18f2450 | 18f2450_usb_bootloader_autostart.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_bootloader_autostart.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_bootloader.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
18f14k50 | 18f14k50_usb_hid_mouse.jal |
18f14k50 | 18f14k50_usb_hid_generic.jal |
18f14k50 | 18f14k50_usb_bootloader_autostart.jal |
18f14k50 | 18f14k50_usb_bootloader.jal |
18f14k50 | 18f14k50_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_bootloader.jal |
18f2450 | 18f2450_usb_bootloader_autostart.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_bootloader_autostart.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_bootloader.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
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
var byte cdc_line_status = 0x00
const byte USB_REQ_SEND_BREAK = 0x23
const byte USB_REQ_SET_LINE_CODING = 0x20
var volatile byte cdc_tx_wr=0
var volatile byte cdc_rx_rd = 0
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_line_coding[7]
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
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 volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
const byte USB_REQ_SET_COMM_FEATURE = 0x02
var bit last_packet_is_full = false
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
var volatile byte cdc_tx_rd=0
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
var volatile byte cdc_rx_wr = 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_GET_LINE_CODING = 0x21
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
var volatile byte cdc_rx_free = USB_CDC_RX_BUFFER_SIZE
No documentation found
var byte cdc_line_status = 0x00
No documentation found
const byte USB_REQ_SEND_BREAK = 0x23
No documentation found
const byte USB_REQ_SET_LINE_CODING = 0x20
No documentation found
var volatile byte cdc_tx_wr=0
No documentation found
var volatile byte cdc_rx_rd = 0
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_line_coding[7]
No documentation found
const byte USB_REQ_SET_CONTROL_LINE_STATE = 0x22
No documentation found
const byte USB_REQ_GET_ENCAPSULATED_RESPONSE = 0x01
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 volatile dword cdc_line_coding_dte_rate at cdc_line_coding[0]
No documentation found
var byte cdc_rx_buffer[USB_CDC_RX_BUFFER_SIZE]
No documentation found
const byte USB_REQ_SET_COMM_FEATURE = 0x02
No documentation found
var bit last_packet_is_full = false
No documentation found
const byte USB_REQ_SEND_ENCAPSULATED_COMMAND = 0x00
No documentation found
var volatile byte cdc_tx_rd=0
No documentation found
const byte USB_REQ_CLEAR_COMM_FEATURE = 0x04
No documentation found
var volatile byte cdc_rx_wr = 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_GET_LINE_CODING = 0x21
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
18f14k50 | 18f14k50_usb_hid_mouse.jal |
18f14k50 | 18f14k50_usb_hid_generic.jal |
18f14k50 | 18f14k50_usb_bootloader_autostart.jal |
18f14k50 | 18f14k50_usb_bootloader.jal |
18f14k50 | 18f14k50_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_hid_keyboard.jal |
18f2450 | 18f2450_usb_bootloader.jal |
18f2450 | 18f2450_usb_bootloader_autostart.jal |
18f2450 | 18f2450_usb_hid_generic.jal |
18f2450 | 18f2450_usb_hid_mouse.jal |
18f4550 | 18f4550_usb_bootloader_autostart.jal |
18f4550 | 18f4550_usb_hid_keyboard.jal |
18f4550 | 18f4550_usb_bootloader.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)
18f14k50 | 18f14k50_usb_serial.jal |
18f2450 | 18f2450_usb_serial.jal |
18f4550 | 18f4550_usb_serial.jal |